Skip to content

Commit 7b83f48

Browse files
author
Joan He
committed
Merge remote-tracking branch 'arcticfoxes/MC-5717' into pr
2 parents c5fec9c + da9e3a4 commit 7b83f48

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Catalog\Controller\Adminhtml\Category;
87

98
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
109

10+
/**
11+
* Class RefreshPath
12+
*/
1113
class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpGetActionInterface
1214
{
1315
/**
@@ -44,6 +46,7 @@ public function execute()
4446
'id' => $categoryId,
4547
'path' => $category->getPath(),
4648
'parentId' => $category->getParentId(),
49+
'level' => $category->getLevel()
4750
]);
4851
}
4952
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function execute()
147147
$parentCategory = $this->getParentCategory($parentId, $storeId);
148148
$category->setPath($parentCategory->getPath());
149149
$category->setParentId($parentCategory->getId());
150+
$category->setLevel(null);
150151
}
151152

152153
/**

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private function setObjectProperty($object, string $propertyName, $value) : void
6666
*/
6767
public function testExecute() : void
6868
{
69-
$value = ['id' => 3, 'path' => '1/2/3', 'parentId' => 2];
70-
$result = '{"id":3,"path":"1/2/3","parentId":"2"}';
69+
$value = ['id' => 3, 'path' => '1/2/3', 'parentId' => 2, 'level' => 2];
70+
$result = '{"id":3,"path":"1/2/3","parentId":"2","level":"2"}';
7171

7272
$requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class);
7373

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@
7777
<dataType>text</dataType>
7878
</settings>
7979
</field>
80+
<field name="level" formElement="hidden">
81+
<argument name="data" xsi:type="array">
82+
<item name="config" xsi:type="array">
83+
<item name="source" xsi:type="string">category</item>
84+
</item>
85+
</argument>
86+
</field>
8087
<field name="store_id" formElement="hidden">
8188
<argument name="data" xsi:type="array">
8289
<item name="config" xsi:type="array">

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
@@ -15,6 +15,7 @@ define([
1515
categoryIdSelector: 'input[name="id"]',
1616
categoryPathSelector: 'input[name="path"]',
1717
categoryParentSelector: 'input[name="parent"]',
18+
categoryLevelSelector: 'input[name="level"]',
1819
refreshUrl: config.refreshUrl
1920
},
2021

@@ -47,6 +48,7 @@ define([
4748
$(this.options.categoryIdSelector).val(data.id).change();
4849
$(this.options.categoryPathSelector).val(data.path).change();
4950
$(this.options.categoryParentSelector).val(data.parentId).change();
51+
$(this.options.categoryLevelSelector).val(data.level).change();
5052
}
5153
}
5254
};

0 commit comments

Comments
 (0)