@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * LOOP to create categories |
50 | 50 | */ |
51 | 51 | for ($i = 0; $i < $_argument['category-number']; $i++) { |
52 | - if(!is_null($_argument['category-name-prefix'])) { |
|
52 | + if (!is_null($_argument['category-name-prefix'])) { |
|
53 | 53 | $name = $_argument['category-name-prefix'] . " " . $i; |
54 | 54 | } |
55 | 55 | else { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ->addAttributeToSelect('name') |
62 | 62 | ->addAttributeToFilter('name', array('eq' => $name)); |
63 | 63 | $_size = $collection->getSize(); |
64 | - if($_size > 0) { |
|
64 | + if ($_size > 0) { |
|
65 | 65 | $output->writeln("<comment>CATEGORY: WITH NAME: '" . $name . "' EXISTS! Skip</comment>\r"); |
66 | 66 | $_argument['category-number']++; |
67 | 67 | continue; |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $category->setDisplayMode('PRODUCTS'); |
77 | 77 | $category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR); |
78 | 78 | |
79 | - if(\Mage::getVersion() === "1.5.1.0") |
|
80 | - $category->setStoreId(array(0,$_argument['store-id'])); |
|
79 | + if (\Mage::getVersion() === "1.5.1.0") |
|
80 | + $category->setStoreId(array(0, $_argument['store-id'])); |
|
81 | 81 | else |
82 | 82 | $category->setStoreId($_argument['store-id']); |
83 | 83 | $parentCategory = \Mage::getModel('catalog/category')->load($_category_root_id); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $category->setDisplayMode('PRODUCTS'); |
99 | 99 | $category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR); |
100 | 100 | |
101 | - if(\Mage::getVersion() === "1.5.1.0") |
|
102 | - $category->setStoreId(array(0,$_argument['store-id'])); |
|
101 | + if (\Mage::getVersion() === "1.5.1.0") |
|
102 | + $category->setStoreId(array(0, $_argument['store-id'])); |
|
103 | 103 | else |
104 | 104 | $category->setStoreId($_argument['store-id']); |
105 | 105 | $parentCategory = \Mage::getModel('catalog/category')->load($_parent_id); |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | $_argument = array(); |
130 | 130 | |
131 | 131 | // STORE ID |
132 | - if(is_null($input->getArgument('store-id'))) { |
|
132 | + if (is_null($input->getArgument('store-id'))) { |
|
133 | 133 | $store_id = \Mage::getModel('core/store')->getCollection() |
134 | 134 | ->addFieldToSelect('*') |
135 | 135 | ->addFieldToFilter('store_id', array('gt' => 0)) |
136 | - ->setOrder('store_id', 'ASC');; |
|
136 | + ->setOrder('store_id', 'ASC'); ; |
|
137 | 137 | $_store_ids = array(); |
138 | 138 | |
139 | 139 | foreach ($store_id as $item) { |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | $_argument['store-id'] = $input->getArgument('store-id'); |
154 | 154 | |
155 | 155 | // NUMBER OF CATEGORIES |
156 | - if(is_null($input->getArgument('category-number'))) { |
|
156 | + if (is_null($input->getArgument('category-number'))) { |
|
157 | 157 | $question = new Question("Please enter the number of categories to create (default 1): ", 1); |
158 | 158 | $question->setValidator(function ($answer) { |
159 | - $answer = (int)($answer); |
|
160 | - if(!is_int($answer) || $answer <= 0) { |
|
159 | + $answer = (int) ($answer); |
|
160 | + if (!is_int($answer) || $answer <= 0) { |
|
161 | 161 | throw new \RuntimeException( |
162 | 162 | 'Please enter an integer value or > 0' |
163 | 163 | ); |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | $_argument['category-number'] = $input->getArgument('category-number'); |
171 | 171 | |
172 | 172 | // NUMBER OF CHILDREN CATEGORIES |
173 | - if(is_null($input->getArgument('children-categories-number'))) { |
|
173 | + if (is_null($input->getArgument('children-categories-number'))) { |
|
174 | 174 | $question = new Question("Number of children for each category created (default: 0 - use '-1' for random from 0 to 5): ", 0); |
175 | 175 | $question->setValidator(function ($answer) { |
176 | - $answer = (int)($answer); |
|
177 | - if(!is_int($answer) || $answer < -1) { |
|
176 | + $answer = (int) ($answer); |
|
177 | + if (!is_int($answer) || $answer < -1) { |
|
178 | 178 | throw new \RuntimeException( |
179 | 179 | "Please enter an integer value or >= -1" |
180 | 180 | ); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | }); |
184 | 184 | $input->setArgument('children-categories-number', $helper->ask($input, $output, $question)); |
185 | 185 | } |
186 | - if($input->getArgument('children-categories-number') == -1) { |
|
186 | + if ($input->getArgument('children-categories-number') == -1) { |
|
187 | 187 | $input->setArgument('children-categories-number', rand(0, 5)); |
188 | 188 | } |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $_argument['children-categories-number'] = $input->getArgument('children-categories-number'); |
192 | 192 | |
193 | 193 | // CATEGORY NAME PREFIX |
194 | - if(is_null($input->getArgument('category-name-prefix'))) { |
|
194 | + if (is_null($input->getArgument('category-name-prefix'))) { |
|
195 | 195 | $question = new Question("Please enter the category name prefix (default '" . self::DEFAULT_CATEGORY_NAME . "'): ", self::DEFAULT_CATEGORY_NAME); |
196 | 196 | $input->setArgument('category-name-prefix', $helper->ask($input, $output, $question)); |
197 | 197 | } |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | for ($i = 0; $i < $_argument['category-number']; $i++) { |
52 | 52 | if(!is_null($_argument['category-name-prefix'])) { |
53 | 53 | $name = $_argument['category-name-prefix'] . " " . $i; |
54 | - } |
|
55 | - else { |
|
54 | + } else { |
|
56 | 55 | $name = self::DEFAULT_CATEGORY_NAME . " " . $i; |
57 | 56 | } |
58 | 57 | |
@@ -76,10 +75,11 @@ discard block |
||
76 | 75 | $category->setDisplayMode('PRODUCTS'); |
77 | 76 | $category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR); |
78 | 77 | |
79 | - if(\Mage::getVersion() === "1.5.1.0") |
|
80 | - $category->setStoreId(array(0,$_argument['store-id'])); |
|
81 | - else |
|
82 | - $category->setStoreId($_argument['store-id']); |
|
78 | + if(\Mage::getVersion() === "1.5.1.0") { |
|
79 | + $category->setStoreId(array(0,$_argument['store-id'])); |
|
80 | + } else { |
|
81 | + $category->setStoreId($_argument['store-id']); |
|
82 | + } |
|
83 | 83 | $parentCategory = \Mage::getModel('catalog/category')->load($_category_root_id); |
84 | 84 | $category->setPath($parentCategory->getPath()); |
85 | 85 | |
@@ -98,10 +98,11 @@ discard block |
||
98 | 98 | $category->setDisplayMode('PRODUCTS'); |
99 | 99 | $category->setIsAnchor(self::DEFAULT_CATEGORY_ANCHOR); |
100 | 100 | |
101 | - if(\Mage::getVersion() === "1.5.1.0") |
|
102 | - $category->setStoreId(array(0,$_argument['store-id'])); |
|
103 | - else |
|
104 | - $category->setStoreId($_argument['store-id']); |
|
101 | + if(\Mage::getVersion() === "1.5.1.0") { |
|
102 | + $category->setStoreId(array(0,$_argument['store-id'])); |
|
103 | + } else { |
|
104 | + $category->setStoreId($_argument['store-id']); |
|
105 | + } |
|
105 | 106 | $parentCategory = \Mage::getModel('catalog/category')->load($_parent_id); |
106 | 107 | $category->setPath($parentCategory->getPath()); |
107 | 108 |