Skip to content

Commit 1c3981f

Browse files
Leonid Poluyanovisitnikov
authored andcommitted
MAGETWO-50224: Inconsistent data during installation of Store
1 parent 3f528b7 commit 1c3981f

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

app/code/Magento/Catalog/Setup/InstallData.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ class InstallData implements InstallDataInterface
2222
*/
2323
private $categorySetupFactory;
2424

25+
/**
26+
* Root category ID
27+
*
28+
* @var int
29+
*/
30+
private $rootCategoryId = 1;
31+
32+
/**
33+
* Default category ID
34+
*
35+
* @var int
36+
*/
37+
private $defaultCategoryId = 2;
38+
2539
/**
2640
* Init
2741
*
@@ -46,28 +60,29 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
4660
$categorySetup->installEntities();
4761
// Create Root Catalog Node
4862
$categorySetup->createCategory()
49-
->load(1)
50-
->setId(1)
63+
->load($this->rootCategoryId)
64+
->setId($this->rootCategoryId)
5165
->setStoreId(0)
52-
->setPath('1')
66+
->setPath($this->rootCategoryId)
5367
->setLevel(0)
5468
->setPosition(0)
5569
->setChildrenCount(0)
5670
->setName('Root Catalog')
5771
->setInitialSetupFlag(true)
5872
->save();
5973

74+
// Create Default Catalog Node
6075
$category = $categorySetup->createCategory();
61-
62-
$categorySetup->createCategory()
76+
$category->load($this->defaultCategoryId)
77+
->setId($this->defaultCategoryId)
6378
->setStoreId(0)
64-
->setPath('1')
79+
->setPath($this->rootCategoryId . '/' . $this->defaultCategoryId)
6580
->setName('Default Category')
6681
->setDisplayMode('PRODUCTS')
67-
->setAttributeSetId($category->getDefaultAttributeSetId())
6882
->setIsActive(1)
6983
->setLevel(1)
7084
->setInitialSetupFlag(true)
85+
->setAttributeSetId($category->getDefaultAttributeSetId())
7186
->save();
7287

7388
$data = [

0 commit comments

Comments
 (0)