Skip to content

Commit 5367cbf

Browse files
author
Roger
committed
Issue 36101: Category selection tree in edit product is not in the same order as set in Catalog->Categories
1 parent 2605796 commit 5367cbf

File tree

1 file changed

+9
-5
lines changed
  • app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier

1 file changed

+9
-5
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
99

10+
use Magento\Backend\Model\Auth\Session;
11+
use Magento\Catalog\Model\Category as CategoryModel;
1012
use Magento\Catalog\Model\Locator\LocatorInterface;
1113
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
12-
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\App\CacheInterface;
15+
use Magento\Framework\App\ObjectManager;
16+
use Magento\Framework\AuthorizationInterface;
1417
use Magento\Framework\DB\Helper as DbHelper;
15-
use Magento\Catalog\Model\Category as CategoryModel;
1618
use Magento\Framework\Exception\LocalizedException;
1719
use Magento\Framework\Serialize\SerializerInterface;
18-
use Magento\Framework\UrlInterface;
1920
use Magento\Framework\Stdlib\ArrayManager;
20-
use Magento\Framework\AuthorizationInterface;
21-
use Magento\Backend\Model\Auth\Session;
21+
use Magento\Framework\UrlInterface;
2222

2323
/**
2424
* Data provider for categories field of product page
@@ -52,6 +52,7 @@ class Categories extends AbstractModifier
5252
* @var array
5353
* @deprecated 101.0.0
5454
* @since 101.0.0
55+
* @see Not use anymore
5556
*/
5657
protected $categoriesTrees = [];
5758

@@ -128,6 +129,7 @@ public function __construct(
128129
*
129130
* @return CacheInterface
130131
* @deprecated 101.0.3
132+
* @see getCategoriesTree
131133
*/
132134
private function getCacheManager(): CacheInterface
133135
{
@@ -442,6 +444,8 @@ private function retrieveCategoriesTree(int $storeId, array $shownCategoriesIds)
442444

443445
$collection->addAttributeToFilter('entity_id', ['in' => array_keys($shownCategoriesIds)])
444446
->addAttributeToSelect(['name', 'is_active', 'parent_id'])
447+
->addAttributeToSort('level', 'asc')
448+
->addAttributeToSort('position', 'asc')
445449
->setStoreId($storeId);
446450

447451
$categoryById = [

0 commit comments

Comments
 (0)