Skip to content

Commit

Permalink
Merge remote-tracking branch 'm2origin/develop' into MAGETWO-50542
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodymyr Klymenko committed Mar 28, 2016
2 parents b62c1a0 + 155d659 commit 39b67cb
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public function execute()
*/
$data = $this->_getSession()->getCategoryData(true);
if (isset($data['general'])) {
if (isset($data['general']['image']['delete'])) {
$data['general']['image'] = null;
} else {
unset($data['general']['image']);
}
$category->addData($data['general']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ public function execute()
$this->messageManager->addError($e->getMessage());
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->_getSession()->setCategoryData($data);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->_getSession()->setCategoryData($data);
} catch (\Exception $e) {
$this->messageManager->addError(__('Something went wrong while saving the category.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
Expand Down
12 changes: 9 additions & 3 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,15 @@ public function getImageUrl()
$url = false;
$image = $this->getImage();
if ($image) {
$url = $this->_storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
) . 'catalog/category/' . $image;
if (is_string($image)) {
$url = $this->_storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
) . 'catalog/category/' . $image;
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('Something went wrong while getting the image url.')
);
}
}
return $url;
}
Expand Down
14 changes: 8 additions & 6 deletions app/code/Magento/Catalog/Model/Category/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,14 @@ public function getAttributesMeta(Type $entityType)
protected function addUseConfigSettings($categoryData)
{
foreach ($this->elementsWithUseConfigSetting as $elementsWithUseConfigSetting) {
if (!isset($categoryData[$elementsWithUseConfigSetting]) ||
($categoryData[$elementsWithUseConfigSetting] == '')
) {
$categoryData['use_config'][$elementsWithUseConfigSetting] = true;
} else {
$categoryData['use_config'][$elementsWithUseConfigSetting] = false;
if (!isset($categoryData['use_config'][$elementsWithUseConfigSetting])) {
if (!isset($categoryData[$elementsWithUseConfigSetting]) ||
($categoryData[$elementsWithUseConfigSetting] == '')
) {
$categoryData['use_config'][$elementsWithUseConfigSetting] = true;
} else {
$categoryData['use_config'][$elementsWithUseConfigSetting] = false;
}
}
}
return $categoryData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,17 @@ class CreateCatalogRuleTest extends AbstractCatalogRuleEntityTest
* @param CatalogRule $catalogPriceRule
* @param string $product
* @param string $conditionEntity
* @param bool $isWithApply
* @param Customer $customer
* @return array
*/
public function testCreate(CatalogRule $catalogPriceRule, $product, $conditionEntity, Customer $customer = null)
{
public function testCreate(
CatalogRule $catalogPriceRule,
$product,
$conditionEntity,
$isWithApply = true,
Customer $customer = null
) {
/** @var CatalogProductSimple $productSimple */
$productSimple = $this->fixtureFactory->createByCode('catalogProductSimple', ['dataset' => $product]);
// Prepare data
Expand All @@ -60,8 +66,10 @@ public function testCreate(CatalogRule $catalogPriceRule, $product, $conditionEn
$this->catalogRuleNew->getEditForm()->fill($catalogPriceRule, null, $replace);
$this->catalogRuleNew->getFormPageActions()->save();

// Apply Catalog Price Rule
$this->catalogRuleIndex->getGridPageActions()->applyRules();
if ($isWithApply) {
// Apply Catalog Price Rule
$this->catalogRuleIndex->getGridPageActions()->applyRules();
}

// Create simple product
$productSimple->persist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function testSaveActionCategoryWithDangerRequest()
);
$this->dispatch('backend/catalog/category/save');
$this->assertSessionMessages(
$this->equalTo(['Something went wrong while saving the category.']),
$this->equalTo(['The value of attribute "is_active" must be set']),
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
}
Expand Down

0 comments on commit 39b67cb

Please sign in to comment.