Skip to content

Commit 63f6f48

Browse files
committed
MAGETWO-57989: Unable to create custom image attribute in category
1 parent 4b3c9cc commit 63f6f48

File tree

2 files changed

+26
-2
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Category
  • dev/tests/integration/testsuite/Magento/Catalog/Model

2 files changed

+26
-2
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ public function __construct(
8181
?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Eav\Model\Config::class);
8282
}
8383

84+
/**
85+
* Filter category data
86+
*
87+
* @deprecated
88+
* @param array $rawData
89+
* @return array
90+
*/
91+
protected function _filterCategoryPostData(array $rawData)
92+
{
93+
$data = $rawData;
94+
if (isset($data['image']) && is_array($data['image'])) {
95+
if (!empty($data['image']['delete'])) {
96+
$data['image'] = null;
97+
} else {
98+
if (isset($data['image'][0]['name']) && isset($data['image'][0]['tmp_name'])) {
99+
$data['image'] = $data['image'][0]['name'];
100+
} else {
101+
unset($data['image']);
102+
}
103+
}
104+
}
105+
return $data;
106+
}
107+
84108
/**
85109
* Category save
86110
*
@@ -239,7 +263,7 @@ public function execute()
239263
* @param array $data
240264
* @return array
241265
*/
242-
public function imagePreprocessing(array $data)
266+
public function imagePreprocessing($data)
243267
{
244268
$entityType = $this->eavConfig->getEntityType(CategoryAttributeInterface::ENTITY_TYPE_CODE);
245269

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function testSaveCategoryWithoutImage()
293293
->isObjectNew(true);
294294

295295
$repository->save($model);
296-
$this->assertNull($model->getImage());
296+
$this->assertEmpty($model->getImage());
297297
}
298298

299299
/**

0 commit comments

Comments
 (0)