@@ -313,7 +313,7 @@ |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | - * @param array $execs |
|
| 316 | + * @param string[] $execs |
|
| 317 | 317 | * @param string $fileName |
| 318 | 318 | * @param InputInterface $input |
| 319 | 319 | * @param OutputInterface $output |
@@ -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 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | protected function execute(InputInterface $input, OutputInterface $output) |
| 193 | 193 | { |
| 194 | 194 | $this->detectMagento($output, true); |
| 195 | - if(!$this->initMagento()) { |
|
| 195 | + if (!$this->initMagento()) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | $this->input = $input; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | // MANAGE ARGUMENTS |
| 204 | 204 | $_argument = $this->manageArguments($input, $output); |
| 205 | - if(!in_array($input->getArgument('locale'), $this->_supported_locales)) { |
|
| 205 | + if (!in_array($input->getArgument('locale'), $this->_supported_locales)) { |
|
| 206 | 206 | $this->output->writeln("<warning>Locale `" . $input->getArgument('locale') . "` not supported, switch to default locale `us_US`.</warning>\r\n"); |
| 207 | 207 | $_argument['locale'] = "en_US"; |
| 208 | 208 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | for ($i = 0; $i < $_argument['values-number']; $i++) { |
| 215 | 215 | |
| 216 | 216 | $value = $this->createValue($_argument['values-type'], $_argument['locale']); |
| 217 | - if(!$this->attributeValueExists($attribute, $value)) { |
|
| 217 | + if (!$this->attributeValueExists($attribute, $value)) { |
|
| 218 | 218 | try { |
| 219 | 219 | $attribute->setData('option', array( |
| 220 | 220 | 'value' => array( |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | $_argument = array(); |
| 249 | 249 | |
| 250 | 250 | // ATTRIBUTE ID |
| 251 | - if(is_null($input->getArgument('attribute-id'))) { |
|
| 251 | + if (is_null($input->getArgument('attribute-id'))) { |
|
| 252 | 252 | $attribute_code = \Mage::getModel('eav/entity_attribute')->getCollection() |
| 253 | 253 | ->addFieldToSelect('*') |
| 254 | 254 | ->addFieldToFilter('entity_type_id', array('eq' => 4)) |
| 255 | 255 | ->addFieldToFilter('backend_type', array('in' => array('int'))) |
| 256 | - ->setOrder('attribute_id', 'ASC');; |
|
| 256 | + ->setOrder('attribute_id', 'ASC'); ; |
|
| 257 | 257 | $_attribute_codes = array(); |
| 258 | 258 | |
| 259 | 259 | foreach ($attribute_code as $item) { |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | $input->setArgument('attribute-id', $response[0]); |
| 270 | 270 | } |
| 271 | 271 | $output->writeln('<info>Attribute code selected: ' . $input->getArgument('attribute-id') . "</info>\r\n"); |
| 272 | - $_argument['attribute-id'] = (int)$input->getArgument('attribute-id'); |
|
| 272 | + $_argument['attribute-id'] = (int) $input->getArgument('attribute-id'); |
|
| 273 | 273 | |
| 274 | 274 | // TYPE OF VALUES |
| 275 | - if(is_null($input->getArgument('values-type'))) { |
|
| 275 | + if (is_null($input->getArgument('values-type'))) { |
|
| 276 | 276 | |
| 277 | 277 | $_values_type = array( |
| 278 | 278 | 'int' => 'int', |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | $_argument['values-type'] = $input->getArgument('values-type'); |
| 295 | 295 | |
| 296 | 296 | // NUMBER OF VALUES |
| 297 | - if(is_null($input->getArgument('values-number'))) { |
|
| 297 | + if (is_null($input->getArgument('values-number'))) { |
|
| 298 | 298 | $question = new Question("Please enter the number of values to create (default 1): ", 1); |
| 299 | 299 | $question->setValidator(function ($answer) { |
| 300 | - $answer = (int)($answer); |
|
| 301 | - if(!is_int($answer) || $answer <= 0) { |
|
| 300 | + $answer = (int) ($answer); |
|
| 301 | + if (!is_int($answer) || $answer <= 0) { |
|
| 302 | 302 | throw new \RuntimeException( |
| 303 | 303 | 'Please enter an integer value or > 0' |
| 304 | 304 | ); |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | protected function createValue($_type, $locale) |
| 324 | 324 | { |
| 325 | - if(!isset($this->faker)) { |
|
| 325 | + if (!isset($this->faker)) { |
|
| 326 | 326 | $this->faker = \Faker\Factory::create($locale); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $options = $attribute_options_model->getAllOptions(false); |
| 365 | 365 | |
| 366 | 366 | foreach ($options as $option) { |
| 367 | - if($option['label'] == $arg_value) { |
|
| 367 | + if ($option['label'] == $arg_value) { |
|
| 368 | 368 | return true; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -205,8 +205,7 @@ |
||
| 205 | 205 | if(!in_array($input->getArgument('locale'), $this->_supported_locales)) { |
| 206 | 206 | $this->output->writeln("<warning>Locale `" . $input->getArgument('locale') . "` not supported, switch to default locale `us_US`.</warning>\r\n"); |
| 207 | 207 | $_argument['locale'] = "en_US"; |
| 208 | - } |
|
| 209 | - else { |
|
| 208 | + } else { |
|
| 210 | 209 | $_argument['locale'] = $input->getArgument('locale'); |
| 211 | 210 | } |
| 212 | 211 | |