Skip to content

Commit 1358132

Browse files
committed
MAGETWO-81926: Category hierarchy isn't updated on Product Admin page
1 parent cc85cbe commit 1358132

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function execute()
3838

3939
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
4040
$resultJson = $this->resultJsonFactory->create();
41-
return $resultJson->setData(['id' => $categoryId, 'path' => $category->getPath()]);
41+
return $resultJson->setData([
42+
'id' => $categoryId,
43+
'path' => $category->getPath(),
44+
'parentid' => $category->getParentID(),
45+
]);
4246
}
4347
}
4448
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ public function execute()
138138
$parentId = isset($categoryPostData['parent']) ? $categoryPostData['parent'] : null;
139139
if ($categoryPostData) {
140140
$category->addData($categoryPostData);
141+
if ($parentId) {
142+
$category->setParentId($parentId);
143+
}
141144
if ($isNewCategory) {
142145
$parentCategory = $this->getParentCategory($parentId, $storeId);
143146
$category->setPath($parentCategory->getPath());

app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ define([
1414
options: {
1515
categoryIdSelector: 'input[name="id"]',
1616
categoryPathSelector: 'input[name="path"]',
17+
categoryParentSelector: 'input[name="parent"]',
1718
refreshUrl: config.refreshUrl
1819
},
1920

@@ -45,6 +46,7 @@ define([
4546
} else {
4647
$(this.options.categoryIdSelector).val(data.id).change();
4748
$(this.options.categoryPathSelector).val(data.path).change();
49+
$(this.options.categoryParentSelector).val(data.parentid).change();
4850
}
4951
}
5052
};

0 commit comments

Comments
 (0)