@@ -22,6 +22,20 @@ class InstallData implements InstallDataInterface
22
22
*/
23
23
private $ categorySetupFactory ;
24
24
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
+
25
39
/**
26
40
* Init
27
41
*
@@ -46,28 +60,29 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
46
60
$ categorySetup ->installEntities ();
47
61
// Create Root Catalog Node
48
62
$ categorySetup ->createCategory ()
49
- ->load (1 )
50
- ->setId (1 )
63
+ ->load ($ this -> rootCategoryId )
64
+ ->setId ($ this -> rootCategoryId )
51
65
->setStoreId (0 )
52
- ->setPath (' 1 ' )
66
+ ->setPath ($ this -> rootCategoryId )
53
67
->setLevel (0 )
54
68
->setPosition (0 )
55
69
->setChildrenCount (0 )
56
70
->setName ('Root Catalog ' )
57
71
->setInitialSetupFlag (true )
58
72
->save ();
59
73
74
+ // Create Default Catalog Node
60
75
$ category = $ categorySetup ->createCategory ();
61
-
62
- $ categorySetup -> createCategory ( )
76
+ $ category -> load ( $ this -> defaultCategoryId )
77
+ -> setId ( $ this -> defaultCategoryId )
63
78
->setStoreId (0 )
64
- ->setPath (' 1 ' )
79
+ ->setPath ($ this -> rootCategoryId . ' / ' . $ this -> defaultCategoryId )
65
80
->setName ('Default Category ' )
66
81
->setDisplayMode ('PRODUCTS ' )
67
- ->setAttributeSetId ($ category ->getDefaultAttributeSetId ())
68
82
->setIsActive (1 )
69
83
->setLevel (1 )
70
84
->setInitialSetupFlag (true )
85
+ ->setAttributeSetId ($ category ->getDefaultAttributeSetId ())
71
86
->save ();
72
87
73
88
$ data = [
0 commit comments