Skip to content

Commit

Permalink
Merge pull request #487 from magento-troll/bugfixes
Browse files Browse the repository at this point in the history
[Troll] Bugfixes
  • Loading branch information
Ganin, Roman(rganin) committed Mar 28, 2016
2 parents 9546277 + d5d3a73 commit 62e7936
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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 @@ -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 62e7936

Please sign in to comment.