true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- true
- Configurable product description %s
', + 'enable_googlecheckout' => '1', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '0', + 'image' => '', + 'image_label' => '', + 'is_returnable' => 'Use config', + 'manufacturer' => '', + 'meta_description' => 'Configurable Product %sConfigurable product description 1
', + 'meta_keyword' => 'Configurable Product 1', + 'meta_title' => 'Configurable Product %s', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => 'Use config', + 'name' => 'Configurable Product %s-option 1', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => 'Block after Info Column', + 'page_layout' => '', + 'price' => '10.0000', + 'quantity_and_stock_status' => 'In Stock', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '0', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '1', + 'tax_class_id' => '2', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '2013-10-25 15:12:32', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => 'configurable-product-%s-option-1', + 'url_path' => 'configurable-product-%s-option-1.html', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '1', + 'weight' => '1.0000', + 'qty' => '111.0000', + 'min_qty' => '0.0000', + 'use_config_min_qty' => '1', + 'is_qty_decimal' => '0', + 'backorders' => '0', + 'use_config_backorders' => '1', + 'min_sale_qty' => '1.0000', + 'use_config_min_sale_qty' => '1', + 'max_sale_qty' => '0.0000', + 'use_config_max_sale_qty' => '1', + 'is_in_stock' => '1', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '1', + 'manage_stock' => '1', + 'use_config_manage_stock' => '1', + 'use_config_qty_increments' => '1', + 'qty_increments' => '0.0000', + 'use_config_enable_qty_inc' => '1', + 'enable_qty_increments' => '0', + 'is_decimal_divided' => '0', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => '', + '_super_attribute_code' => '', + '_super_attribute_option' => '', + '_super_attribute_price_corr' => '', + ], + [ + 'sku' => 'Configurable Product %s-option 2', + '_store' => '', + '_attribute_set' => 'Default', + '_type' => 'simple', + '_category' => $productCategory, + '_root_category' => $productRootCategory, + '_product_websites' => $productWebsite, + 'color' => '', + 'configurable_variations' => 'option 2', + 'cost' => '', + 'country_of_manufacture' => '', + 'created_at' => '2013-10-25 15:12:35', + 'custom_design' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'custom_layout_update' => '', + 'description' => 'Configurable product description %s
', + 'enable_googlecheckout' => '1', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '0', + 'image' => '', + 'image_label' => '', + 'is_returnable' => 'Use config', + 'manufacturer' => '', + 'meta_description' => 'Configurable Product %sConfigurable product description 1
', + 'meta_keyword' => 'Configurable Product 1', + 'meta_title' => 'Configurable Product %s', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => 'Use config', + 'name' => 'Configurable Product %s-option 2', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => 'Block after Info Column', + 'page_layout' => '', + 'price' => '10.0000', + 'quantity_and_stock_status' => 'In Stock', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '0', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '1', + 'tax_class_id' => '2', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '2013-10-25 15:12:35', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => 'configurable-product-%s-option-2', + 'url_path' => 'configurable-product-%s-option-2.html', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '1', + 'weight' => '1.0000', + 'qty' => '111.0000', + 'min_qty' => '0.0000', + 'use_config_min_qty' => '1', + 'is_qty_decimal' => '0', + 'backorders' => '0', + 'use_config_backorders' => '1', + 'min_sale_qty' => '1.0000', + 'use_config_min_sale_qty' => '1', + 'max_sale_qty' => '0.0000', + 'use_config_max_sale_qty' => '1', + 'is_in_stock' => '1', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '1', + 'manage_stock' => '1', + 'use_config_manage_stock' => '1', + 'use_config_qty_increments' => '1', + 'qty_increments' => '0.0000', + 'use_config_enable_qty_inc' => '1', + 'enable_qty_increments' => '0', + 'is_decimal_divided' => '0', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => '', + '_super_attribute_code' => '', + '_super_attribute_option' => '', + '_super_attribute_price_corr' => '', + ], + [ + 'sku' => 'Configurable Product %s-option 3', + '_store' => '', + '_attribute_set' => 'Default', + '_type' => 'simple', + '_category' => $productCategory, + '_root_category' => $productRootCategory, + '_product_websites' => $productWebsite, + 'color' => '', + 'configurable_variations' => 'option 3', + 'cost' => '', + 'country_of_manufacture' => '', + 'created_at' => '2013-10-25 15:12:37', + 'custom_design' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'custom_layout_update' => '', + 'description' => 'Configurable product description %s
', + 'enable_googlecheckout' => '1', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '0', + 'image' => '', + 'image_label' => '', + 'is_returnable' => 'Use config', + 'manufacturer' => '', + 'meta_description' => 'Configurable Product %sConfigurable product description 1
', + 'meta_keyword' => 'Configurable Product 1', + 'meta_title' => 'Configurable Product %s', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => 'Use config', + 'name' => 'Configurable Product %s-option 3', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => 'Block after Info Column', + 'page_layout' => '', + 'price' => '10.0000', + 'quantity_and_stock_status' => 'In Stock', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '0', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '1', + 'tax_class_id' => '2', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '2013-10-25 15:12:37', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => 'configurable-product-%s-option-3', + 'url_path' => 'configurable-product-%s-option-3.html', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '1', + 'weight' => '1.0000', + 'qty' => '111.0000', + 'min_qty' => '0.0000', + 'use_config_min_qty' => '1', + 'is_qty_decimal' => '0', + 'backorders' => '0', + 'use_config_backorders' => '1', + 'min_sale_qty' => '1.0000', + 'use_config_min_sale_qty' => '1', + 'max_sale_qty' => '0.0000', + 'use_config_max_sale_qty' => '1', + 'is_in_stock' => '1', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '1', + 'manage_stock' => '1', + 'use_config_manage_stock' => '1', + 'use_config_qty_increments' => '1', + 'qty_increments' => '0.0000', + 'use_config_enable_qty_inc' => '1', + 'enable_qty_increments' => '0', + 'is_decimal_divided' => '0', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => '', + '_super_attribute_code' => '', + '_super_attribute_option' => '', + '_super_attribute_price_corr' => '', + ], + [ + 'sku' => 'Configurable Product %s', + '_store' => '', + '_attribute_set' => 'Default', + '_type' => 'configurable', + '_category' => $productCategory, + '_root_category' => $productRootCategory, + '_product_websites' => $productWebsite, + 'color' => '', + 'configurable_variations' => '', + 'cost' => '', + 'country_of_manufacture' => '', + 'created_at' => '2013-10-25 15:12:39', + 'custom_design' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'custom_layout_update' => '', + 'description' => 'Configurable product description %s
', + 'enable_googlecheckout' => '1', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '1', + 'image' => '', + 'image_label' => '', + 'is_returnable' => 'Use config', + 'manufacturer' => '', + 'meta_description' => 'Configurable Product %sConfigurable product description %s
', + 'meta_keyword' => 'Configurable Product %s', + 'meta_title' => 'Configurable Product %s', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => 'Use config', + 'name' => 'Configurable Product %s', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => 'Block after Info Column', + 'page_layout' => '', + 'price' => '10.0000', + 'quantity_and_stock_status' => 'In Stock', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '1', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '1', + 'tax_class_id' => '2', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '2013-10-25 15:12:39', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => 'configurable-product-%s', + 'url_path' => 'configurable-product-%s.html', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '4', + 'weight' => '', + 'qty' => 333, + 'min_qty' => '0.0000', + 'use_config_min_qty' => '1', + 'is_qty_decimal' => '0', + 'backorders' => '0', + 'use_config_backorders' => '1', + 'min_sale_qty' => '1.0000', + 'use_config_min_sale_qty' => '1', + 'max_sale_qty' => '0.0000', + 'use_config_max_sale_qty' => '1', + 'is_in_stock' => '1', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '1', + 'manage_stock' => '1', + 'use_config_manage_stock' => '1', + 'use_config_qty_increments' => '1', + 'qty_increments' => '0.0000', + 'use_config_enable_qty_inc' => '1', + 'enable_qty_increments' => '0', + 'is_decimal_divided' => '0', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => 'Configurable Product %s-option 1', + '_super_attribute_code' => 'configurable_variations', + '_super_attribute_option' => 'option 1', + '_super_attribute_price_corr' => '10.0000', + ], + [ + 'sku' => '', + '_store' => '', + '_attribute_set' => '', + '_type' => '', + '_category' => '', + '_root_category' => '', + '_product_websites' => '', + 'color' => '', + 'configurable_variations' => '', + 'cost' => '', + 'country_of_manufacture' => '', + 'created_at' => '', + 'custom_design' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'custom_layout_update' => '', + 'description' => '', + 'enable_googlecheckout' => '', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '', + 'image' => '', + 'image_label' => '', + 'is_returnable' => '', + 'manufacturer' => '', + 'meta_description' => '', + 'meta_keyword' => '', + 'meta_title' => '', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => '', + 'name' => '', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => '', + 'page_layout' => '', + 'price' => '', + 'quantity_and_stock_status' => '', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '', + 'tax_class_id' => '', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => '', + 'url_path' => '', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '', + 'weight' => '', + 'qty' => 333, + 'min_qty' => '', + 'use_config_min_qty' => '', + 'is_qty_decimal' => '', + 'backorders' => '', + 'use_config_backorders' => '', + 'min_sale_qty' => '', + 'use_config_min_sale_qty' => '', + 'max_sale_qty' => '', + 'use_config_max_sale_qty' => '', + 'is_in_stock' => '', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '', + 'manage_stock' => '', + 'use_config_manage_stock' => '', + 'use_config_qty_increments' => '', + 'qty_increments' => '', + 'use_config_enable_qty_inc' => '', + 'enable_qty_increments' => '', + 'is_decimal_divided' => '', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => 'Configurable Product %s-option 2', + '_super_attribute_code' => 'configurable_variations', + '_super_attribute_option' => 'option 2', + '_super_attribute_price_corr' => '20.0000', + ], + [ + 'sku' => '', + '_store' => '', + '_attribute_set' => '', + '_type' => '', + '_category' => '', + '_root_category' => '', + '_product_websites' => '', + 'color' => '', + 'configurable_variations' => '', + 'cost' => '', + 'country_of_manufacture' => '', + 'created_at' => '', + 'custom_design' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'custom_layout_update' => '', + 'description' => '', + 'enable_googlecheckout' => '', + 'gallery' => '', + 'gift_message_available' => '', + 'gift_wrapping_available' => '', + 'gift_wrapping_price' => '', + 'has_options' => '', + 'image' => '', + 'image_label' => '', + 'is_returnable' => '', + 'manufacturer' => '', + 'meta_description' => '', + 'meta_keyword' => '', + 'meta_title' => '', + 'minimal_price' => '', + 'msrp' => '', + 'msrp_display_actual_price_type' => '', + 'name' => '', + 'news_from_date' => '', + 'news_to_date' => '', + 'options_container' => '', + 'page_layout' => '', + 'price' => '', + 'quantity_and_stock_status' => '', + 'related_tgtr_position_behavior' => '', + 'related_tgtr_position_limit' => '', + 'required_options' => '', + 'short_description' => '', + 'small_image' => '', + 'small_image_label' => '', + 'special_from_date' => '', + 'special_price' => '', + 'special_to_date' => '', + 'status' => '', + 'tax_class_id' => '', + 'thumbnail' => '', + 'thumbnail_label' => '', + 'updated_at' => '', + 'upsell_tgtr_position_behavior' => '', + 'upsell_tgtr_position_limit' => '', + 'url_key' => '', + 'url_path' => '', + 'variations' => '', + 'variations_1382710717' => '', + 'variations_1382710773' => '', + 'variations_1382710861' => '', + 'visibility' => '', + 'weight' => '', + 'qty' => 333, + 'min_qty' => '', + 'use_config_min_qty' => '', + 'is_qty_decimal' => '', + 'backorders' => '', + 'use_config_backorders' => '', + 'min_sale_qty' => '', + 'use_config_min_sale_qty' => '', + 'max_sale_qty' => '', + 'use_config_max_sale_qty' => '', + 'is_in_stock' => '', + 'notify_stock_qty' => '', + 'use_config_notify_stock_qty' => '', + 'manage_stock' => '', + 'use_config_manage_stock' => '', + 'use_config_qty_increments' => '', + 'qty_increments' => '', + 'use_config_enable_qty_inc' => '', + 'enable_qty_increments' => '', + 'is_decimal_divided' => '', + '_related_sku' => '', + '_related_position' => '', + '_crosssell_sku' => '', + '_crosssell_position' => '', + '_upsell_sku' => '', + '_upsell_position' => '', + '_associated_sku' => '', + '_associated_default_qty' => '', + '_associated_position' => '', + '_tier_price_website' => '', + '_tier_price_customer_group' => '', + '_tier_price_qty' => '', + '_tier_price_price' => '', + '_group_price_website' => '', + '_group_price_customer_group' => '', + '_group_price_price' => '', + '_media_attribute_id' => '', + '_media_image' => '', + '_media_label' => '', + '_media_position' => '', + '_media_is_disabled' => '', + '_super_products_sku' => 'Configurable Product %s-option 3', + '_super_attribute_code' => 'configurable_variations', + '_super_attribute_option' => 'option 3', + '_super_attribute_price_corr' => '30.0000', + ], + ]; -$result = []; -//Get all websites -$websites = $storeManager->getWebsites(); -foreach ($websites as $website) { - $websiteCode = $website->getCode(); - //Get all groups - $websiteGroups = $website->getGroups(); - foreach ($websiteGroups as $websiteGroup) { - $websiteGroupRootCategory = $websiteGroup->getRootCategoryId(); - $category->load($websiteGroupRootCategory); - $categoryResource = $category->getResource(); - $rootCategoryName = $category->getName(); - //Get all categories - $resultsCategories = $categoryResource->getAllChildren($category); - foreach ($resultsCategories as $resultsCategory) { - $category->load($resultsCategory); - $structure = explode('/', $category->getPath()); - $pathSize = count($structure); - if ($pathSize > 1) { - $path = []; - for ($i = 1; $i < $pathSize; $i++) { - $path[] = $category->load($structure[$i])->getName(); + } + + /** + * {@inheritdoc} + */ + public function execute() + { + $configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 90); + $this->application->resetObjectManager(); + + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + /** @var $category \Magento\Catalog\Model\Category */ + $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + + $result = []; + //Get all websites + $websites = $storeManager->getWebsites(); + foreach ($websites as $website) { + $websiteCode = $website->getCode(); + //Get all groups + $websiteGroups = $website->getGroups(); + foreach ($websiteGroups as $websiteGroup) { + $websiteGroupRootCategory = $websiteGroup->getRootCategoryId(); + $category->load($websiteGroupRootCategory); + $categoryResource = $category->getResource(); + $rootCategoryName = $category->getName(); + //Get all categories + $resultsCategories = $categoryResource->getAllChildren($category); + foreach ($resultsCategories as $resultsCategory) { + $category->load($resultsCategory); + $structure = explode('/', $category->getPath()); + $pathSize = count($structure); + if ($pathSize > 1) { + $path = []; + for ($i = 1; $i < $pathSize; $i++) { + $path[] = $category->load($structure[$i])->getName(); + } + array_shift($path); + $resultsCategoryName = implode('/', $path); + } else { + $resultsCategoryName = $category->getName(); + } + //Deleted root categories + if (trim($resultsCategoryName) != '') { + $result[$resultsCategory] = [$websiteCode, $resultsCategoryName, $rootCategoryName]; + } } - array_shift($path); - $resultsCategoryName = implode('/', $path); - } else { - $resultsCategoryName = $category->getName(); - } - //Deleted root categories - if (trim($resultsCategoryName) != '') { - $result[$resultsCategory] = [$websiteCode, $resultsCategoryName, $rootCategoryName]; } } - } -} -$result = array_values($result); + $result = array_values($result); -$productWebsite = function ($index) use ($result) { - return $result[$index % count($result)][0]; -}; -$productCategory = function ($index) use ($result) { - return $result[$index % count($result)][1]; -}; -$productRootCategory = function ($index) use ($result) { - return $result[$index % count($result)][2]; -}; + $productWebsite = function ($index) use ($result) { + return $result[$index % count($result)][0]; + }; + $productCategory = function ($index) use ($result) { + return $result[$index % count($result)][1]; + }; + $productRootCategory = function ($index) use ($result) { + return $result[$index % count($result)][2]; + }; -$headers = [ - 'sku', - '_store', - '_attribute_set', - '_type', - '_category', - '_root_category', - '_product_websites', - 'color', - 'configurable_variations', - 'cost', - 'country_of_manufacture', - 'created_at', - 'custom_design', - 'custom_design_from', - 'custom_design_to', - 'custom_layout_update', - 'description', - 'enable_googlecheckout', - 'gallery', - 'gift_message_available', - 'gift_wrapping_available', - 'gift_wrapping_price', - 'has_options', - 'image', - 'image_label', - 'is_returnable', - 'manufacturer', - 'meta_description', - 'meta_keyword', - 'meta_title', - 'minimal_price', - 'msrp', - 'msrp_display_actual_price_type', - 'name', - 'news_from_date', - 'news_to_date', - 'options_container', - 'page_layout', - 'price', - 'quantity_and_stock_status', - 'related_tgtr_position_behavior', - 'related_tgtr_position_limit', - 'required_options', - 'short_description', - 'small_image', - 'small_image_label', - 'special_from_date', - 'special_price', - 'special_to_date', - 'status', - 'tax_class_id', - 'thumbnail', - 'thumbnail_label', - 'updated_at', - 'upsell_tgtr_position_behavior', - 'upsell_tgtr_position_limit', - 'url_key', - 'url_path', - 'variations', - 'variations_1382710717', - 'variations_1382710773', - 'variations_1382710861', - 'visibility', - 'weight', - 'qty', - 'min_qty', - 'use_config_min_qty', - 'is_qty_decimal', - 'backorders', - 'use_config_backorders', - 'min_sale_qty', - 'use_config_min_sale_qty', - 'max_sale_qty', - 'use_config_max_sale_qty', - 'is_in_stock', - 'notify_stock_qty', - 'use_config_notify_stock_qty', - 'manage_stock', - 'use_config_manage_stock', - 'use_config_qty_increments', - 'qty_increments', - 'use_config_enable_qty_inc', - 'enable_qty_increments', - 'is_decimal_divided', - '_related_sku', - '_related_position', - '_crosssell_sku', - '_crosssell_position', - '_upsell_sku', - '_upsell_position', - '_associated_sku', - '_associated_default_qty', - '_associated_position', - '_tier_price_website', - '_tier_price_customer_group', - '_tier_price_qty', - '_tier_price_price', - '_group_price_website', - '_group_price_customer_group', - '_group_price_price', - '_media_attribute_id', - '_media_image', - '_media_label', - '_media_position', - '_media_is_disabled', - '_super_products_sku', - '_super_attribute_code', - '_super_attribute_option', - '_super_attribute_price_corr', -]; + /** + * Create configurable products + */ + $pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern(); + $pattern->setHeaders($this->getHeaders()); + $pattern->setRowsSet($this->getRows($productCategory, $productRootCategory, $productWebsite)); -$rows = [ - [ - 'sku' => 'Configurable Product %s-option 1', - '_store' => '', - '_attribute_set' => 'Default', - '_type' => 'simple', - '_category' => $productCategory, - '_root_category' => $productRootCategory, - '_product_websites' => $productWebsite, - 'color' => '', - 'configurable_variations' => 'option 1', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '2013-10-25 15:12:32', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => 'Configurable product description %s
', - 'enable_googlecheckout' => '1', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '0', - 'image' => '', - 'image_label' => '', - 'is_returnable' => 'Use config', - 'manufacturer' => '', - 'meta_description' => 'Configurable Product %sConfigurable product description 1
', - 'meta_keyword' => 'Configurable Product 1', - 'meta_title' => 'Configurable Product %s', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => 'Use config', - 'name' => 'Configurable Product %s-option 1', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => 'Block after Info Column', - 'page_layout' => '', - 'price' => '10.0000', - 'quantity_and_stock_status' => 'In Stock', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '0', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '1', - 'tax_class_id' => '2', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '2013-10-25 15:12:32', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => 'configurable-product-%s-option-1', - 'url_path' => 'configurable-product-%s-option-1.html', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '1', - 'weight' => '1.0000', - 'qty' => '111.0000', - 'min_qty' => '0.0000', - 'use_config_min_qty' => '1', - 'is_qty_decimal' => '0', - 'backorders' => '0', - 'use_config_backorders' => '1', - 'min_sale_qty' => '1.0000', - 'use_config_min_sale_qty' => '1', - 'max_sale_qty' => '0.0000', - 'use_config_max_sale_qty' => '1', - 'is_in_stock' => '1', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '1', - 'manage_stock' => '1', - 'use_config_manage_stock' => '1', - 'use_config_qty_increments' => '1', - 'qty_increments' => '0.0000', - 'use_config_enable_qty_inc' => '1', - 'enable_qty_increments' => '0', - 'is_decimal_divided' => '0', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => '', - '_super_attribute_code' => '', - '_super_attribute_option' => '', - '_super_attribute_price_corr' => '', - ], - [ - 'sku' => 'Configurable Product %s-option 2', - '_store' => '', - '_attribute_set' => 'Default', - '_type' => 'simple', - '_category' => $productCategory, - '_root_category' => $productRootCategory, - '_product_websites' => $productWebsite, - 'color' => '', - 'configurable_variations' => 'option 2', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '2013-10-25 15:12:35', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => 'Configurable product description %s
', - 'enable_googlecheckout' => '1', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '0', - 'image' => '', - 'image_label' => '', - 'is_returnable' => 'Use config', - 'manufacturer' => '', - 'meta_description' => 'Configurable Product %sConfigurable product description 1
', - 'meta_keyword' => 'Configurable Product 1', - 'meta_title' => 'Configurable Product %s', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => 'Use config', - 'name' => 'Configurable Product %s-option 2', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => 'Block after Info Column', - 'page_layout' => '', - 'price' => '10.0000', - 'quantity_and_stock_status' => 'In Stock', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '0', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '1', - 'tax_class_id' => '2', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '2013-10-25 15:12:35', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => 'configurable-product-%s-option-2', - 'url_path' => 'configurable-product-%s-option-2.html', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '1', - 'weight' => '1.0000', - 'qty' => '111.0000', - 'min_qty' => '0.0000', - 'use_config_min_qty' => '1', - 'is_qty_decimal' => '0', - 'backorders' => '0', - 'use_config_backorders' => '1', - 'min_sale_qty' => '1.0000', - 'use_config_min_sale_qty' => '1', - 'max_sale_qty' => '0.0000', - 'use_config_max_sale_qty' => '1', - 'is_in_stock' => '1', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '1', - 'manage_stock' => '1', - 'use_config_manage_stock' => '1', - 'use_config_qty_increments' => '1', - 'qty_increments' => '0.0000', - 'use_config_enable_qty_inc' => '1', - 'enable_qty_increments' => '0', - 'is_decimal_divided' => '0', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => '', - '_super_attribute_code' => '', - '_super_attribute_option' => '', - '_super_attribute_price_corr' => '', - ], - [ - 'sku' => 'Configurable Product %s-option 3', - '_store' => '', - '_attribute_set' => 'Default', - '_type' => 'simple', - '_category' => $productCategory, - '_root_category' => $productRootCategory, - '_product_websites' => $productWebsite, - 'color' => '', - 'configurable_variations' => 'option 3', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '2013-10-25 15:12:37', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => 'Configurable product description %s
', - 'enable_googlecheckout' => '1', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '0', - 'image' => '', - 'image_label' => '', - 'is_returnable' => 'Use config', - 'manufacturer' => '', - 'meta_description' => 'Configurable Product %sConfigurable product description 1
', - 'meta_keyword' => 'Configurable Product 1', - 'meta_title' => 'Configurable Product %s', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => 'Use config', - 'name' => 'Configurable Product %s-option 3', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => 'Block after Info Column', - 'page_layout' => '', - 'price' => '10.0000', - 'quantity_and_stock_status' => 'In Stock', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '0', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '1', - 'tax_class_id' => '2', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '2013-10-25 15:12:37', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => 'configurable-product-%s-option-3', - 'url_path' => 'configurable-product-%s-option-3.html', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '1', - 'weight' => '1.0000', - 'qty' => '111.0000', - 'min_qty' => '0.0000', - 'use_config_min_qty' => '1', - 'is_qty_decimal' => '0', - 'backorders' => '0', - 'use_config_backorders' => '1', - 'min_sale_qty' => '1.0000', - 'use_config_min_sale_qty' => '1', - 'max_sale_qty' => '0.0000', - 'use_config_max_sale_qty' => '1', - 'is_in_stock' => '1', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '1', - 'manage_stock' => '1', - 'use_config_manage_stock' => '1', - 'use_config_qty_increments' => '1', - 'qty_increments' => '0.0000', - 'use_config_enable_qty_inc' => '1', - 'enable_qty_increments' => '0', - 'is_decimal_divided' => '0', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => '', - '_super_attribute_code' => '', - '_super_attribute_option' => '', - '_super_attribute_price_corr' => '', - ], - [ - 'sku' => 'Configurable Product %s', - '_store' => '', - '_attribute_set' => 'Default', - '_type' => 'configurable', - '_category' => $productCategory, - '_root_category' => $productRootCategory, - '_product_websites' => $productWebsite, - 'color' => '', - 'configurable_variations' => '', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '2013-10-25 15:12:39', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => 'Configurable product description %s
', - 'enable_googlecheckout' => '1', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '1', - 'image' => '', - 'image_label' => '', - 'is_returnable' => 'Use config', - 'manufacturer' => '', - 'meta_description' => 'Configurable Product %sConfigurable product description %s
', - 'meta_keyword' => 'Configurable Product %s', - 'meta_title' => 'Configurable Product %s', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => 'Use config', - 'name' => 'Configurable Product %s', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => 'Block after Info Column', - 'page_layout' => '', - 'price' => '10.0000', - 'quantity_and_stock_status' => 'In Stock', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '1', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '1', - 'tax_class_id' => '2', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '2013-10-25 15:12:39', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => 'configurable-product-%s', - 'url_path' => 'configurable-product-%s.html', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '4', - 'weight' => '', - 'qty' => 333, - 'min_qty' => '0.0000', - 'use_config_min_qty' => '1', - 'is_qty_decimal' => '0', - 'backorders' => '0', - 'use_config_backorders' => '1', - 'min_sale_qty' => '1.0000', - 'use_config_min_sale_qty' => '1', - 'max_sale_qty' => '0.0000', - 'use_config_max_sale_qty' => '1', - 'is_in_stock' => '1', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '1', - 'manage_stock' => '1', - 'use_config_manage_stock' => '1', - 'use_config_qty_increments' => '1', - 'qty_increments' => '0.0000', - 'use_config_enable_qty_inc' => '1', - 'enable_qty_increments' => '0', - 'is_decimal_divided' => '0', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => 'Configurable Product %s-option 1', - '_super_attribute_code' => 'configurable_variations', - '_super_attribute_option' => 'option 1', - '_super_attribute_price_corr' => '10.0000', - ], - [ - 'sku' => '', - '_store' => '', - '_attribute_set' => '', - '_type' => '', - '_category' => '', - '_root_category' => '', - '_product_websites' => '', - 'color' => '', - 'configurable_variations' => '', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => '', - 'enable_googlecheckout' => '', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '', - 'image' => '', - 'image_label' => '', - 'is_returnable' => '', - 'manufacturer' => '', - 'meta_description' => '', - 'meta_keyword' => '', - 'meta_title' => '', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => '', - 'name' => '', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => '', - 'page_layout' => '', - 'price' => '', - 'quantity_and_stock_status' => '', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '', - 'tax_class_id' => '', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => '', - 'url_path' => '', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '', - 'weight' => '', - 'qty' => 333, - 'min_qty' => '', - 'use_config_min_qty' => '', - 'is_qty_decimal' => '', - 'backorders' => '', - 'use_config_backorders' => '', - 'min_sale_qty' => '', - 'use_config_min_sale_qty' => '', - 'max_sale_qty' => '', - 'use_config_max_sale_qty' => '', - 'is_in_stock' => '', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '', - 'manage_stock' => '', - 'use_config_manage_stock' => '', - 'use_config_qty_increments' => '', - 'qty_increments' => '', - 'use_config_enable_qty_inc' => '', - 'enable_qty_increments' => '', - 'is_decimal_divided' => '', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => 'Configurable Product %s-option 2', - '_super_attribute_code' => 'configurable_variations', - '_super_attribute_option' => 'option 2', - '_super_attribute_price_corr' => '20.0000', - ], - [ - 'sku' => '', - '_store' => '', - '_attribute_set' => '', - '_type' => '', - '_category' => '', - '_root_category' => '', - '_product_websites' => '', - 'color' => '', - 'configurable_variations' => '', - 'cost' => '', - 'country_of_manufacture' => '', - 'created_at' => '', - 'custom_design' => '', - 'custom_design_from' => '', - 'custom_design_to' => '', - 'custom_layout_update' => '', - 'description' => '', - 'enable_googlecheckout' => '', - 'gallery' => '', - 'gift_message_available' => '', - 'gift_wrapping_available' => '', - 'gift_wrapping_price' => '', - 'has_options' => '', - 'image' => '', - 'image_label' => '', - 'is_returnable' => '', - 'manufacturer' => '', - 'meta_description' => '', - 'meta_keyword' => '', - 'meta_title' => '', - 'minimal_price' => '', - 'msrp' => '', - 'msrp_display_actual_price_type' => '', - 'name' => '', - 'news_from_date' => '', - 'news_to_date' => '', - 'options_container' => '', - 'page_layout' => '', - 'price' => '', - 'quantity_and_stock_status' => '', - 'related_tgtr_position_behavior' => '', - 'related_tgtr_position_limit' => '', - 'required_options' => '', - 'short_description' => '', - 'small_image' => '', - 'small_image_label' => '', - 'special_from_date' => '', - 'special_price' => '', - 'special_to_date' => '', - 'status' => '', - 'tax_class_id' => '', - 'thumbnail' => '', - 'thumbnail_label' => '', - 'updated_at' => '', - 'upsell_tgtr_position_behavior' => '', - 'upsell_tgtr_position_limit' => '', - 'url_key' => '', - 'url_path' => '', - 'variations' => '', - 'variations_1382710717' => '', - 'variations_1382710773' => '', - 'variations_1382710861' => '', - 'visibility' => '', - 'weight' => '', - 'qty' => 333, - 'min_qty' => '', - 'use_config_min_qty' => '', - 'is_qty_decimal' => '', - 'backorders' => '', - 'use_config_backorders' => '', - 'min_sale_qty' => '', - 'use_config_min_sale_qty' => '', - 'max_sale_qty' => '', - 'use_config_max_sale_qty' => '', - 'is_in_stock' => '', - 'notify_stock_qty' => '', - 'use_config_notify_stock_qty' => '', - 'manage_stock' => '', - 'use_config_manage_stock' => '', - 'use_config_qty_increments' => '', - 'qty_increments' => '', - 'use_config_enable_qty_inc' => '', - 'enable_qty_increments' => '', - 'is_decimal_divided' => '', - '_related_sku' => '', - '_related_position' => '', - '_crosssell_sku' => '', - '_crosssell_position' => '', - '_upsell_sku' => '', - '_upsell_position' => '', - '_associated_sku' => '', - '_associated_default_qty' => '', - '_associated_position' => '', - '_tier_price_website' => '', - '_tier_price_customer_group' => '', - '_tier_price_qty' => '', - '_tier_price_price' => '', - '_group_price_website' => '', - '_group_price_customer_group' => '', - '_group_price_price' => '', - '_media_attribute_id' => '', - '_media_image' => '', - '_media_label' => '', - '_media_position' => '', - '_media_is_disabled' => '', - '_super_products_sku' => 'Configurable Product %s-option 3', - '_super_attribute_code' => 'configurable_variations', - '_super_attribute_option' => 'option 3', - '_super_attribute_price_corr' => '30.0000', - ], -]; + /** @var \Magento\ImportExport\Model\Import $import */ + $import = $this->application->getObjectManager()->create( + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']] + ); -/** - * Create configurable products - */ -$pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern(); -$pattern->setHeaders($headers); -$pattern->setRowsSet($rows); + $source = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($pattern, $configurablesCount); + // it is not obvious, but the validateSource() will actually save import queue data to DB + $import->validateSource($source); + // this converts import queue into actual entities + $import->importSource(); + + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating configurable products'; + } -/** @var \Magento\ImportExport\Model\Import $import */ -$import = $this->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']] -); + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return [ + 'configurable_products' => 'Configurable products' + ]; + } +} -$source = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($pattern, $configurablesCount); -// it is not obvious, but the validateSource() will actually save import queue data to DB -$import->validateSource($source); -// this converts import queue into actual entities -$import->importSource(); +return new ConfigurableProductsFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/customers.php b/dev/tools/performance-toolkit/fixtures/customers.php index 33fe42eb63baa..df42bc283a221 100644 --- a/dev/tools/performance-toolkit/fixtures/customers.php +++ b/dev/tools/performance-toolkit/fixtures/customers.php @@ -3,80 +3,117 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$customersNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('customers', 10); -$this->resetObjectManager(); -/** @var \Magento\Store\Model\StoreManager $storeManager */ -$storeManager = $this->getObjectManager()->create('Magento\Store\Model\StoreManager'); -/** @var $category \Magento\Catalog\Model\Category */ -$category = $this->getObjectManager()->get('Magento\Catalog\Model\Category'); -/** @var $defaultStoreView \Magento\Store\Model\Store */ -$defaultStoreView = $storeManager->getDefaultStoreView(); -$defaultStoreViewId = $defaultStoreView->getStoreId(); -$defaultStoreViewCode = $defaultStoreView->getCode(); +/** + * Class CustomersFixture + */ +class CustomersFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 60; -$result = []; -//Get all websites -$websites = $storeManager->getWebsites(); -foreach ($websites as $website) { - $result[] = $website->getCode(); -} -$result = array_values($result); + /** + * {@inheritdoc} + */ + public function execute() + { + $customersNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('customers', 10); + $this->application->resetObjectManager(); + + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + /** @var $category \Magento\Catalog\Model\Category */ + $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); + /** @var $defaultStoreView \Magento\Store\Model\Store */ + $defaultStoreView = $storeManager->getDefaultStoreView(); + $defaultStoreViewId = $defaultStoreView->getStoreId(); + $defaultStoreViewCode = $defaultStoreView->getCode(); + + $result = []; + //Get all websites + $websites = $storeManager->getWebsites(); + foreach ($websites as $website) { + $result[] = $website->getCode(); + } + $result = array_values($result); -$productWebsite = function ($index) use ($result) { - return $result[$index % count($result)]; -}; + $productWebsite = function ($index) use ($result) { + return $result[$index % count($result)]; + }; + + $pattern = [ + 'email' => 'user_%s@example.com', + '_website' => $productWebsite, + '_store' => $defaultStoreViewCode, + 'confirmation' => null, + 'created_at' => '30-08-2012 17:43', + 'created_in' => 'Default', + 'default_billing' => '1', + 'default_shipping' => '1', + 'disable_auto_group_change' => '0', + 'dob' => '12-10-1991', + 'firstname' => 'Firstname', + 'gender' => 'Male', + 'group_id' => '1', + 'lastname' => 'Lastname', + 'middlename' => '', + 'password_hash' => '', + 'prefix' => null, + 'rp_token' => null, + 'rp_token_created_at' => null, + 'store_id' => $defaultStoreViewId, + 'suffix' => null, + 'taxvat' => null, + 'website_id' => '1', + 'password' => '123123q', + '_address_city' => 'Fayetteville', + '_address_company' => '', + '_address_country_id' => 'US', + '_address_fax' => '', + '_address_firstname' => 'Anthony', + '_address_lastname' => 'Nealy', + '_address_middlename' => '', + '_address_postcode' => '123123', + '_address_prefix' => '', + '_address_region' => 'Arkansas', + '_address_street' => '123 Freedom Blvd. #123', + '_address_suffix' => '', + '_address_telephone' => '022-333-4455', + '_address_vat_id' => '', + '_address_default_billing_' => '1', + '_address_default_shipping_' => '1', + ]; + $generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator($pattern, $customersNumber); + /** @var Magento\ImportExport\Model\Import $import */ + $import = $this->application->getObjectManager()->create( + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']] + ); + // it is not obvious, but the validateSource() will actually save import queue data to DB + $import->validateSource($generator); + // this converts import queue into actual entities + $import->importSource(); + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating customers'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return [ + 'customers' => 'Customers' + ]; + } +} -$pattern = [ - 'email' => 'user_%s@example.com', - '_website' => $productWebsite, - '_store' => $defaultStoreViewCode, - 'confirmation' => null, - 'created_at' => '30-08-2012 17:43', - 'created_in' => 'Default', - 'default_billing' => '1', - 'default_shipping' => '1', - 'disable_auto_group_change' => '0', - 'dob' => '12-10-1991', - 'firstname' => 'Firstname', - 'gender' => 'Male', - 'group_id' => '1', - 'lastname' => 'Lastname', - 'middlename' => '', - 'password_hash' => '', - 'prefix' => null, - 'rp_token' => null, - 'rp_token_created_at' => null, - 'store_id' => $defaultStoreViewId, - 'suffix' => null, - 'taxvat' => null, - 'website_id' => '1', - 'password' => '123123q', - '_address_city' => 'Fayetteville', - '_address_company' => '', - '_address_country_id' => 'US', - '_address_fax' => '', - '_address_firstname' => 'Anthony', - '_address_lastname' => 'Nealy', - '_address_middlename' => '', - '_address_postcode' => '123123', - '_address_prefix' => '', - '_address_region' => 'Arkansas', - '_address_street' => '123 Freedom Blvd. #123', - '_address_suffix' => '', - '_address_telephone' => '022-333-4455', - '_address_vat_id' => '', - '_address_default_billing_' => '1', - '_address_default_shipping_' => '1', -]; -$generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator($pattern, $customersNumber); -/** @var Magento\ImportExport\Model\Import $import */ -$import = $this->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'customer_composite', 'behavior' => 'append']] -); -// it is not obvious, but the validateSource() will actually save import queue data to DB -$import->validateSource($generator); -// this converts import queue into actual entities -$import->importSource(); +return new CustomersFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/disable_form_key_usage.php b/dev/tools/performance-toolkit/fixtures/disable_form_key_usage.php index f16dc686a1b27..71abcefd2e67c 100644 --- a/dev/tools/performance-toolkit/fixtures/disable_form_key_usage.php +++ b/dev/tools/performance-toolkit/fixtures/disable_form_key_usage.php @@ -3,17 +3,52 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$this->resetObjectManager(); + /** - * @var \Magento\Framework\App\Config\Value $configData + * Class DisableFormKeyUsageFixture */ -$configData = $this->getObjectManager()->create('Magento\Framework\App\Config\Value'); -$configData->setPath(\Magento\Backend\Model\Url::XML_PATH_USE_SECURE_KEY) - ->setScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) - ->setScopeId(0) - ->setValue(0) - ->save(); +class DisableFormKeyUsageFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 100; + + /** + * {@inheritdoc} + */ + public function execute() + { + $this->application->resetObjectManager(); + /** + * @var \Magento\Framework\App\Config\Value $configData + */ + $configData = $this->application->getObjectManager()->create('Magento\Framework\App\Config\Value'); + $configData->setPath(\Magento\Backend\Model\Url::XML_PATH_USE_SECURE_KEY) + ->setScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) + ->setScopeId(0) + ->setValue(0) + ->save(); + + $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface') + ->clean([\Magento\Framework\App\Config::CACHE_TAG]); + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Disabling form key usage'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return []; + } +} -$this->getObjectManager()->get('Magento\Framework\App\CacheInterface') - ->clean([\Magento\Framework\App\Config::CACHE_TAG]); +return new DisableFormKeyUsageFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/eav_variations.php b/dev/tools/performance-toolkit/fixtures/eav_variations.php index ccaa2fcf94ab0..2d2fbc8951743 100644 --- a/dev/tools/performance-toolkit/fixtures/eav_variations.php +++ b/dev/tools/performance-toolkit/fixtures/eav_variations.php @@ -3,83 +3,119 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -define('ATTRIBUTE_SET_ID', 4); -$this->resetObjectManager(); -/* @var $model \Magento\Catalog\Model\Resource\Eav\Attribute */ -$model = $this->getObjectManager()->create('Magento\Catalog\Model\Resource\Eav\Attribute'); -/* @var $helper \Magento\Catalog\Helper\Product */ -$helper = $this->getObjectManager()->get('Magento\Catalog\Helper\Product'); -/** @var \Magento\Store\Model\StoreManager $storeManager */ -$storeManager = $this->getObjectManager()->create('Magento\Store\Model\StoreManager'); -$stores = $storeManager->getStores(); -$storeViewsCount = count($stores); +define('ATTRIBUTE_SET_ID', 4); -$data = [ - 'frontend_label' => array_fill(0, $storeViewsCount + 1, 'configurable variations'), - 'frontend_input' => 'select', - 'is_required' => '0', - 'option' => [ - 'order' => [ - 'option_0' => '1', - 'option_1' => '2', - 'option_2' => '3', - ], - 'value' => [ - 'option_0' => array_fill(0, $storeViewsCount + 1, 'option 1'), - 'option_1' => array_fill(0, $storeViewsCount + 1, 'option 2'), - 'option_2' => array_fill(0, $storeViewsCount + 1, 'option 3'), - ], - 'delete' => [ - 'option_0' => '', - 'option_1' => '', - 'option_2' => '', - ], - ], - 'default' => ['option_0'], - 'attribute_code' => 'configurable_variations', - 'is_global' => '1', - 'default_value_text' => '', - 'default_value_yesno' => '0', - 'default_value_date' => '', - 'default_value_textarea' => '', - 'is_unique' => '0', - 'is_searchable' => '0', - 'is_visible_in_advanced_search' => '0', - 'is_comparable' => '0', - 'is_filterable' => '0', - 'is_filterable_in_search' => '0', - 'is_used_for_promo_rules' => '0', - 'is_html_allowed_on_front' => '1', - 'is_visible_on_front' => '0', - 'used_in_product_listing' => '0', - 'used_for_sort_by' => '0', - 'source_model' => null, - 'backend_model' => null, - 'apply_to' => [], - 'backend_type' => 'int', - 'entity_type_id' => 4, - 'is_user_defined' => 1, -]; /** - * The logic is not obvious, but looking to the controller logic for configurable products this attribute requires - * to be saved twice to become a child of Default attribute set and become available for creating and|or importing - * configurable products. - * See MAGETWO-16492 + * Class EavVariationsFixture */ -$model->addData($data); -$attributeSet = $this->getObjectManager()->get('Magento\Eav\Model\Entity\Attribute\Set'); -$attributeSet->load(ATTRIBUTE_SET_ID); -$model->setAttributeSetId(ATTRIBUTE_SET_ID) - ->setAttributeGroupId($attributeSet->getDefaultGroupId(4)) - ->save(); +class EavVariationsFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 40; + + /** + * {@inheritdoc} + */ + public function execute() + { + $this->application->resetObjectManager(); + + /* @var $model \Magento\Catalog\Model\Resource\Eav\Attribute */ + $model = $this->application->getObjectManager()->create('Magento\Catalog\Model\Resource\Eav\Attribute'); + /* @var $helper \Magento\Catalog\Helper\Product */ + $helper = $this->application->getObjectManager()->get('Magento\Catalog\Helper\Product'); + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + $stores = $storeManager->getStores(); + $storeViewsCount = count($stores); + + $data = [ + 'frontend_label' => array_fill(0, $storeViewsCount + 1, 'configurable variations'), + 'frontend_input' => 'select', + 'is_required' => '0', + 'option' => [ + 'order' => [ + 'option_0' => '1', + 'option_1' => '2', + 'option_2' => '3', + ], + 'value' => [ + 'option_0' => array_fill(0, $storeViewsCount + 1, 'option 1'), + 'option_1' => array_fill(0, $storeViewsCount + 1, 'option 2'), + 'option_2' => array_fill(0, $storeViewsCount + 1, 'option 3'), + ], + 'delete' => [ + 'option_0' => '', + 'option_1' => '', + 'option_2' => '', + ], + ], + 'default' => ['option_0'], + 'attribute_code' => 'configurable_variations', + 'is_global' => '1', + 'default_value_text' => '', + 'default_value_yesno' => '0', + 'default_value_date' => '', + 'default_value_textarea' => '', + 'is_unique' => '0', + 'is_searchable' => '0', + 'is_visible_in_advanced_search' => '0', + 'is_comparable' => '0', + 'is_filterable' => '0', + 'is_filterable_in_search' => '0', + 'is_used_for_promo_rules' => '0', + 'is_html_allowed_on_front' => '1', + 'is_visible_on_front' => '0', + 'used_in_product_listing' => '0', + 'used_for_sort_by' => '0', + 'source_model' => null, + 'backend_model' => null, + 'apply_to' => [], + 'backend_type' => 'int', + 'entity_type_id' => 4, + 'is_user_defined' => 1, + ]; + /** + * The logic is not obvious, but looking to the controller logic for configurable products this attribute + * requires to be saved twice to become a child of Default attribute set and become available for creating + * and|or importing configurable products. + * See MAGETWO-16492 + */ + $model->addData($data); + $attributeSet = $this->application->getObjectManager()->get('Magento\Eav\Model\Entity\Attribute\Set'); + $attributeSet->load(ATTRIBUTE_SET_ID); + $model->setAttributeSetId(ATTRIBUTE_SET_ID) + ->setAttributeGroupId($attributeSet->getDefaultGroupId(4)) + ->save(); + + $model->setAttributeSetId(ATTRIBUTE_SET_ID); + $model->save(); + + /* @var $cache \Magento\Framework\App\CacheInterface */ + $cache = $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface'); + + $cacheKey = \Magento\Eav\Model\Config::ATTRIBUTES_CACHE_ID . \Magento\Catalog\Model\Product::ENTITY; + $cache->remove($cacheKey); + } -$model->setAttributeSetId(ATTRIBUTE_SET_ID); -$model->save(); + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating configurable EAV variations'; + } -/* @var $cache \Magento\Framework\App\CacheInterface */ -$cache = $this->getObjectManager()->get('Magento\Framework\App\CacheInterface'); + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return []; + } +} -$cacheKey = \Magento\Eav\Model\Config::ATTRIBUTES_CACHE_ID . \Magento\Catalog\Model\Product::ENTITY; -$cache->remove($cacheKey); +return new EavVariationsFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/shipping_flatrate_enabled.php b/dev/tools/performance-toolkit/fixtures/shipping_flatrate_enabled.php index 5eb443ea30ac1..c68bbb747358f 100644 --- a/dev/tools/performance-toolkit/fixtures/shipping_flatrate_enabled.php +++ b/dev/tools/performance-toolkit/fixtures/shipping_flatrate_enabled.php @@ -3,17 +3,52 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$this->resetObjectManager(); + /** - * @var \Magento\Framework\App\Config\Value $configData + * Class EnableShippingFlatRateFixture */ -$configData = $this->getObjectManager()->create('Magento\Framework\App\Config\Value'); -$configData->setPath('carriers/flatrate/active') - ->setScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) - ->setScopeId(0) - ->setValue(1) - ->save(); +class EnableShippingFlatRateFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 110; + + /** + * {@inheritdoc} + */ + public function execute() + { + $this->application->resetObjectManager(); + /** + * @var \Magento\Framework\App\Config\Value $configData + */ + $configData = $this->application->getObjectManager()->create('Magento\Framework\App\Config\Value'); + $configData->setPath('carriers/flatrate/active') + ->setScope(\Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) + ->setScopeId(0) + ->setValue(1) + ->save(); + + $this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface') + ->clean([\Magento\Framework\App\Config::CACHE_TAG]); + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Enabling Flat Rate shipping method'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return []; + } +} -$this->getObjectManager()->get('Magento\Framework\App\CacheInterface') - ->clean([\Magento\Framework\App\Config::CACHE_TAG]); +return new EnableShippingFlatRateFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/simple_products.php b/dev/tools/performance-toolkit/fixtures/simple_products.php index 0abda3f0fe492..26d676455aa1d 100644 --- a/dev/tools/performance-toolkit/fixtures/simple_products.php +++ b/dev/tools/performance-toolkit/fixtures/simple_products.php @@ -3,95 +3,145 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$simpleProductsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('simple_products', 180); -$this->resetObjectManager(); -/** @var \Magento\Store\Model\StoreManager $storeManager */ -$storeManager = $this->getObjectManager()->create('Magento\Store\Model\StoreManager'); -/** @var $category \Magento\Catalog\Model\Category */ -$category = $this->getObjectManager()->get('Magento\Catalog\Model\Category'); +/** + * Class SimpleProductsFixture + */ +class SimpleProductsFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 30; + + /** + * {@inheritdoc} + */ + public function execute() + { + $simpleProductsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('simple_products', 180); + $this->application->resetObjectManager(); + + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + /** @var $category \Magento\Catalog\Model\Category */ + $category = $this->application->getObjectManager()->get('Magento\Catalog\Model\Category'); -$result = []; -//Get all websites -$websites = $storeManager->getWebsites(); -foreach ($websites as $website) { - $websiteCode = $website->getCode(); - //Get all groups - $websiteGroups = $website->getGroups(); - foreach ($websiteGroups as $websiteGroup) { - $websiteGroupRootCategory = $websiteGroup->getRootCategoryId(); - $category->load($websiteGroupRootCategory); - $categoryResource = $category->getResource(); - //Get all categories - $resultsCategories = $categoryResource->getAllChildren($category); - foreach ($resultsCategories as $resultsCategory) { - $category->load($resultsCategory); - $structure = explode('/', $category->getPath()); - $pathSize = count($structure); - if ($pathSize > 1) { - $path = []; - for ($i = 1; $i < $pathSize; $i++) { - $path[] = $category->load($structure[$i])->getName(); + $result = []; + //Get all websites + $websites = $storeManager->getWebsites(); + foreach ($websites as $website) { + $websiteCode = $website->getCode(); + //Get all groups + $websiteGroups = $website->getGroups(); + foreach ($websiteGroups as $websiteGroup) { + $websiteGroupRootCategory = $websiteGroup->getRootCategoryId(); + $category->load($websiteGroupRootCategory); + $categoryResource = $category->getResource(); + //Get all categories + $resultsCategories = $categoryResource->getAllChildren($category); + foreach ($resultsCategories as $resultsCategory) { + $category->load($resultsCategory); + $structure = explode('/', $category->getPath()); + $pathSize = count($structure); + if ($pathSize > 1) { + $path = []; + for ($i = 1; $i < $pathSize; $i++) { + $path[] = $category->load($structure[$i])->getName(); + } + array_shift($path); + $resultsCategoryName = implode('/', $path); + } else { + $resultsCategoryName = $category->getName(); + } + //Deleted root categories + if (trim($resultsCategoryName) != '') { + $result[$resultsCategory] = [$websiteCode, $resultsCategoryName]; + } } - array_shift($path); - $resultsCategoryName = implode('/', $path); - } else { - $resultsCategoryName = $category->getName(); - } - //Deleted root categories - if (trim($resultsCategoryName) != '') { - $result[$resultsCategory] = [$websiteCode, $resultsCategoryName]; } } + $result = array_values($result); + + $productWebsite = function ($index) use ($result) { + return $result[$index % count($result)][0]; + }; + $productCategory = function ($index) use ($result) { + return $result[$index % count($result)][1]; + }; + + $generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator( + $this->getPattern($productWebsite, $productCategory), + $simpleProductsCount + ); + /** @var \Magento\ImportExport\Model\Import $import */ + $import = $this->application->getObjectManager()->create( + 'Magento\ImportExport\Model\Import', + ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']] + ); + // it is not obvious, but the validateSource() will actually save import queue data to DB + $import->validateSource($generator); + // this converts import queue into actual entities + $import->importSource(); } -} -$result = array_values($result); -$productWebsite = function ($index) use ($result) { - return $result[$index % count($result)][0]; -}; -$productCategory = function ($index) use ($result) { - return $result[$index % count($result)][1]; -}; + /** + * Get pattern for product import + * + * @param Closure|int|string $productWebsiteClosure + * @param Closure|int|string $productCategoryClosure + * @return array + */ + protected function getPattern($productWebsiteClosure, $productCategoryClosure) + { + return [ + '_attribute_set' => 'Default', + '_type' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, + '_product_websites' => $productWebsiteClosure, + '_category' => $productCategoryClosure, + 'name' => 'Simple Product %s', + 'short_description' => 'Short simple product description %s', + 'weight' => 1, + 'description' => 'Full simple product Description %s', + 'sku' => 'product_dynamic_%s', + 'price' => 10, + 'visibility' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH, + 'status' => \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, + 'tax_class_id' => 2, + /** + * actually it saves without stock data, but by default system won't show on the + * frontend products out of stock + */ + 'is_in_stock' => 1, + 'qty' => 100500, + 'use_config_min_qty' => '1', + 'use_config_backorders' => '1', + 'use_config_min_sale_qty' => '1', + 'use_config_max_sale_qty' => '1', + 'use_config_notify_stock_qty' => '1', + 'use_config_manage_stock' => '1', + 'use_config_qty_increments' => '1', + 'use_config_enable_qty_inc' => '1', + ]; + } -/** - * Create products - */ -$pattern = [ - '_attribute_set' => 'Default', - '_type' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, - '_product_websites' => $productWebsite, - '_category' => $productCategory, - 'name' => 'Simple Product %s', - 'short_description' => 'Short simple product description %s', - 'weight' => 1, - 'description' => 'Full simple product Description %s', - 'sku' => 'product_dynamic_%s', - 'price' => 10, - 'visibility' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH, - 'status' => \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, - 'tax_class_id' => 2, + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating simple products'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return [ + 'simple_products' => 'Simple products' + ]; + } +} - // actually it saves without stock data, but by default system won't show on the frontend products out of stock - 'is_in_stock' => 1, - 'qty' => 100500, - 'use_config_min_qty' => '1', - 'use_config_backorders' => '1', - 'use_config_min_sale_qty' => '1', - 'use_config_max_sale_qty' => '1', - 'use_config_notify_stock_qty' => '1', - 'use_config_manage_stock' => '1', - 'use_config_qty_increments' => '1', - 'use_config_enable_qty_inc' => '1', -]; -$generator = new \Magento\ToolkitFramework\ImportExport\Fixture\Generator($pattern, $simpleProductsCount); -/** @var \Magento\ImportExport\Model\Import $import */ -$import = $this->getObjectManager()->create( - 'Magento\ImportExport\Model\Import', - ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']] -); -// it is not obvious, but the validateSource() will actually save import queue data to DB -$import->validateSource($generator); -// this converts import queue into actual entities -$import->importSource(); +return new SimpleProductsFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/stores.php b/dev/tools/performance-toolkit/fixtures/stores.php index 04beb627bf582..ac56367cc2701 100644 --- a/dev/tools/performance-toolkit/fixtures/stores.php +++ b/dev/tools/performance-toolkit/fixtures/stores.php @@ -3,138 +3,177 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$websitesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('websites', 2); -$storeGroupsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_groups', 3); -$storesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_views', 5); -$this->resetObjectManager(); - -/** @var \Magento\Store\Model\StoreManager $storeManager */ -$storeManager = $this->getObjectManager()->create('Magento\Store\Model\StoreManager'); -/** @var $category \Magento\Catalog\Model\Category */ -$category = $this->getObjectManager()->create('Magento\Catalog\Model\Category'); - -/** @var $defaultWebsite \Magento\Store\Model\Website */ -$defaultWebsite = $storeManager->getWebsite(); -/** @var $defaultStoreGroup \Magento\Store\Model\Group */ -$defaultStoreGroup = $storeManager->getGroup(); -/** @var $defaultStoreView \Magento\Store\Model\Store */ -$defaultStoreView = $storeManager->getDefaultStoreView(); - -$defaultParentCategoryId = $storeManager->getStore()->getRootCategoryId(); - -$defaultWebsiteId = $defaultWebsite->getId(); -$defaultStoreGroupId = $defaultStoreGroup->getId(); -$defaultStoreViewId = $defaultStoreView->getId(); - -$websitesId = []; -$groupsId = []; - -//Create $websitesCount websites -for ($i = 0; $i < $websitesCount; $i++) { - $websiteId = null; - if ($i == 0) { - $websiteId = $defaultWebsiteId; - } - $website = clone $defaultWebsite; - $websiteCode = sprintf('website_%d', $i + 1); - $websiteName = sprintf('Website %d', $i + 1); - $website->addData( - [ - 'website_id' => $websiteId, - 'code' => $websiteCode, - 'name' => $websiteName, - 'is_default' => (int)$i == 0, - ] - ); - $website->save(); - $websitesId[$i] = $website->getId(); - usleep(20); -} - -//Create $storeGroupsCount websites -$websiteNumber = 0; -for ($i = 0; $i < $storeGroupsCount; $i++) { - $websiteId = $websitesId[$websiteNumber]; - $groupId = null; - $parentCategoryId = null; - $categoryPath = '1'; - $storeGroupName = sprintf('Store Group %d - website_id_%d', $i + 1, $websiteId); +/** + * Class StoresFixture + */ +class StoresFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 10; + + /** + * {@inheritdoc} + */ + public function execute() + { + $websitesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('websites', 2); + $storeGroupsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_groups', 3); + $storesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_views', 5); + $this->application->resetObjectManager(); + + /** @var \Magento\Store\Model\StoreManager $storeManager */ + $storeManager = $this->application->getObjectManager()->create('Magento\Store\Model\StoreManager'); + /** @var $category \Magento\Catalog\Model\Category */ + $category = $this->application->getObjectManager()->create('Magento\Catalog\Model\Category'); + + /** @var $defaultWebsite \Magento\Store\Model\Website */ + $defaultWebsite = $storeManager->getWebsite(); + /** @var $defaultStoreGroup \Magento\Store\Model\Group */ + $defaultStoreGroup = $storeManager->getGroup(); + /** @var $defaultStoreView \Magento\Store\Model\Store */ + $defaultStoreView = $storeManager->getDefaultStoreView(); + + $defaultParentCategoryId = $storeManager->getStore()->getRootCategoryId(); + + $defaultWebsiteId = $defaultWebsite->getId(); + $defaultStoreGroupId = $defaultStoreGroup->getId(); + $defaultStoreViewId = $defaultStoreView->getId(); + + $websitesId = []; + $groupsId = []; + + //Create $websitesCount websites + for ($i = 0; $i < $websitesCount; $i++) { + $websiteId = null; + if ($i == 0) { + $websiteId = $defaultWebsiteId; + } + $website = clone $defaultWebsite; + $websiteCode = sprintf('website_%d', $i + 1); + $websiteName = sprintf('Website %d', $i + 1); + $website->addData( + [ + 'website_id' => $websiteId, + 'code' => $websiteCode, + 'name' => $websiteName, + 'is_default' => (int)$i == 0, + ] + ); + $website->save(); + $websitesId[$i] = $website->getId(); + usleep(20); + } - if ($i == 0 && $websiteId == $defaultWebsiteId) { - $groupId = $defaultStoreGroupId; - $parentCategoryId = $defaultParentCategoryId; - $categoryPath = '1/' . $defaultParentCategoryId; - } + //Create $storeGroupsCount websites + $websiteNumber = 0; + for ($i = 0; $i < $storeGroupsCount; $i++) { + $websiteId = $websitesId[$websiteNumber]; + $groupId = null; + $parentCategoryId = null; + $categoryPath = '1'; + + $storeGroupName = sprintf('Store Group %d - website_id_%d', $i + 1, $websiteId); + + if ($i == 0 && $websiteId == $defaultWebsiteId) { + $groupId = $defaultStoreGroupId; + $parentCategoryId = $defaultParentCategoryId; + $categoryPath = '1/' . $defaultParentCategoryId; + } + + $category->setId($parentCategoryId) + ->setName("Category $storeGroupName") + ->setPath($categoryPath) + ->setLevel(1) + ->setAvailableSortBy('name') + ->setDefaultSortBy('name') + ->setIsActive(true) + ->save(); + + $storeGroup = clone $defaultStoreGroup; + $storeGroup->addData( + [ + 'group_id' => $groupId, + 'website_id' => $websiteId, + 'name' => $storeGroupName, + 'root_category_id' => $category->getId(), + ] + ); + $storeGroup->save(); + $groupsId[$websiteId][] = $storeGroup->getId(); + + $websiteNumber++; + if ($websiteNumber == count($websitesId)) { + $websiteNumber = 0; + } + usleep(20); + } - $category->setId($parentCategoryId) - ->setName("Category $storeGroupName") - ->setPath($categoryPath) - ->setLevel(1) - ->setAvailableSortBy('name') - ->setDefaultSortBy('name') - ->setIsActive(true) - ->save(); - - $storeGroup = clone $defaultStoreGroup; - $storeGroup->addData( - [ - 'group_id' => $groupId, - 'website_id' => $websiteId, - 'name' => $storeGroupName, - 'root_category_id' => $category->getId(), - ] - ); - $storeGroup->save(); - $groupsId[$websiteId][] = $storeGroup->getId(); - - $websiteNumber++; - if ($websiteNumber == count($websitesId)) { + //Create $storesCount stores $websiteNumber = 0; + $groupNumber = 0; + for ($i = 0; $i < $storesCount; $i++) { + $websiteId = $websitesId[$websiteNumber]; + $groupId = $groupsId[$websiteId][$groupNumber]; + $storeId = null; + if ($i == 0 && $groupId == $defaultStoreGroupId) { + $storeId = $defaultStoreViewId; + } + $store = clone $defaultStoreView; + $storeCode = sprintf('store_view_%d_w_%d_g_%d', $i + 1, $websiteId, $groupId); + $storeName = sprintf('Store view %d - website_id_%d - group_id_%d', $i + 1, $websiteId, $groupId); + $store->addData( + [ + 'store_id' => $storeId, + 'name' => $storeName, + 'website_id' => $websiteId, + 'group_id' => $groupId, + ] + ); + + if ($storeId == null) { + $store->addData( + [ + 'code' => $storeCode, + ] + ); + } + + $store->save(); + + $groupNumber++; + if ($groupNumber == count($groupsId[$websiteId])) { + $groupNumber = 0; + $websiteNumber++; + if ($websiteNumber == count($websitesId)) { + $websiteNumber = 0; + } + } + usleep(20); + } } - usleep(20); -} -//Create $storesCount stores -$websiteNumber = 0; -$groupNumber = 0; -for ($i = 0; $i < $storesCount; $i++) { - $websiteId = $websitesId[$websiteNumber]; - $groupId = $groupsId[$websiteId][$groupNumber]; - $storeId = null; - if ($i == 0 && $groupId == $defaultStoreGroupId) { - $storeId = $defaultStoreViewId; - } - $store = clone $defaultStoreView; - $storeCode = sprintf('store_view_%d_w_%d_g_%d', $i + 1, $websiteId, $groupId); - $storeName = sprintf('Store view %d - website_id_%d - group_id_%d', $i + 1, $websiteId, $groupId); - $store->addData( - [ - 'store_id' => $storeId, - 'name' => $storeName, - 'website_id' => $websiteId, - 'group_id' => $groupId, - ] - ); - - if ($storeId == null) { - $store->addData( - [ - 'code' => $storeCode, - ] - ); + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating websites, stores and store views'; } - $store->save(); - - $groupNumber++; - if ($groupNumber == count($groupsId[$websiteId])) { - $groupNumber = 0; - $websiteNumber++; - if ($websiteNumber == count($websitesId)) { - $websiteNumber = 0; - } + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return [ + 'websites' => 'Websites', + 'store_groups' => 'Store Groups', + 'store_views' => 'Store Views' + ]; } - usleep(20); } + +return new StoresFixture($this); diff --git a/dev/tools/performance-toolkit/fixtures/tax_rates.php b/dev/tools/performance-toolkit/fixtures/tax_rates.php index ee64573b153ba..d4a9cbbba16f6 100644 --- a/dev/tools/performance-toolkit/fixtures/tax_rates.php +++ b/dev/tools/performance-toolkit/fixtures/tax_rates.php @@ -3,29 +3,68 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -/** @var \Magento\ToolkitFramework\Application $this */ -$this->resetObjectManager(); -/** Clean predefined tax rates to maintain consistency */ -/** @var $collection Magento\Tax\Model\Resource\Calculation\Rate\Collection */ -$collection = $this->getObjectManager()->get('Magento\Tax\Model\Resource\Calculation\Rate\Collection'); - -/** @var $model Magento\Tax\Model\Calculation\Rate */ -$model = $this->getObjectManager()->get('Magento\Tax\Model\Calculation\Rate'); - -foreach ($collection->getAllIds() as $id) { - $model->setId($id); - $model->delete(); -} + /** - * Import tax rates with import handler + * Class TaxRatesFixture */ -$filename = realpath(__DIR__ . '/tax_rates.csv'); -$file = [ - 'name' => $filename, - 'type' => 'application/vnd.ms-excel', - 'tmp_name' => $filename, - 'error' => 0, - 'size' => filesize($filename), -]; -$importHandler = $this->getObjectManager()->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); -$importHandler->importFromCsvFile($file); +class TaxRatesFixture extends \Magento\ToolkitFramework\Fixture +{ + /** + * @var int + */ + protected $priority = 90; + + /** + * {@inheritdoc} + */ + public function execute() + { + $this->application->resetObjectManager(); + /** Clean predefined tax rates to maintain consistency */ + /** @var $collection Magento\Tax\Model\Resource\Calculation\Rate\Collection */ + $collection = $this->application->getObjectManager() + ->get('Magento\Tax\Model\Resource\Calculation\Rate\Collection'); + + /** @var $model Magento\Tax\Model\Calculation\Rate */ + $model = $this->application->getObjectManager() + ->get('Magento\Tax\Model\Calculation\Rate'); + + foreach ($collection->getAllIds() as $id) { + $model->setId($id); + $model->delete(); + } + /** + * Import tax rates with import handler + */ + $filename = realpath(__DIR__ . '/tax_rates.csv'); + $file = [ + 'name' => $filename, + 'type' => 'application/vnd.ms-excel', + 'tmp_name' => $filename, + 'error' => 0, + 'size' => filesize($filename), + ]; + $importHandler = $this->application->getObjectManager() + ->create('Magento\TaxImportExport\Model\Rate\CsvImportHandler'); + $importHandler->importFromCsvFile($file); + + } + + /** + * {@inheritdoc} + */ + public function getActionTitle() + { + return 'Generating tax rates'; + } + + /** + * {@inheritdoc} + */ + public function introduceParamLabels() + { + return []; + } +} + +return new TaxRatesFixture($this); diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php index 02eba95303127..083ac9fefbc6f 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php +++ b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Application.php @@ -18,6 +18,16 @@ class Application */ const AREA_CODE = 'adminhtml'; + /** + * Fixtures directory + */ + const FIXTURES_DIR = '/../../../fixtures'; + + /** + * Fixtures file name pattern + */ + const FIXTURE_PATTERN = '*.php'; + /** * Application object * @@ -38,23 +48,36 @@ class Application /** * List of fixtures applied to the application * - * @var array + * @var \Magento\ToolkitFramework\Fixture[] */ protected $_fixtures = []; + /** + * Parameters labels + * + * @var array + */ + protected $_paramLabels = []; + /** * @var string */ protected $_applicationBaseDir; + /** + * @var array + */ + protected $_initArguments; + /** * @param string $applicationBaseDir * @param \Magento\Framework\Shell $shell */ - public function __construct($applicationBaseDir, \Magento\Framework\Shell $shell) + public function __construct($applicationBaseDir, \Magento\Framework\Shell $shell, array $initArguments) { $this->_applicationBaseDir = $applicationBaseDir; $this->_shell = $shell; + $this->_initArguments = $initArguments; } /** @@ -108,41 +131,49 @@ public function reindex() } /** - * Work on application, so that it has all and only $fixtures applied. May require reinstall, if - * excessive fixtures has been applied before. + * Load fixtures * - * @param array $fixtures - * - * @return void + * @return $this + * @throws \Exception */ - public function applyFixtures(array $fixtures) + public function loadFixtures() { - // Apply fixtures - $fixturesToApply = array_diff($fixtures, $this->_fixtures); - if (!$fixturesToApply) { - return; + if (!is_readable(__DIR__ . self::FIXTURES_DIR)) { + throw new \Exception( + 'Fixtures set directory `' . __DIR__ . self::FIXTURES_DIR . '` is not readable or does not exists.' + ); } - - $this->_bootstrap(); - foreach ($fixturesToApply as $fixtureFile) { - $this->applyFixture($fixtureFile); + $files = glob(__DIR__ . self::FIXTURES_DIR . DIRECTORY_SEPARATOR . self::FIXTURE_PATTERN); + foreach ($files as $file) { + /** @var \Magento\ToolkitFramework\Fixture $fixture */ + $fixture = require realpath($file); + $this->_fixtures[$fixture->getPriority()] = $fixture; } - $this->_fixtures = $fixtures; - - $this->reindex() - ->_updateFilesystemPermissions(); + ksort($this->_fixtures); + foreach ($this->_fixtures as $fixture) { + $this->_paramLabels = array_merge($this->_paramLabels, $fixture->introduceParamLabels()); + } + return $this; } /** - * Apply fixture file + * Get param labels * - * @param string $fixtureFilename + * @return array + */ + public function getParamLabels() + { + return $this->_paramLabels; + } + + /** + * Get fixtures * - * @return void + * @return Fixture[] */ - public function applyFixture($fixtureFilename) + public function getFixtures() { - require $fixtureFilename; + return $this->_fixtures; } /** @@ -153,8 +184,11 @@ public function applyFixture($fixtureFilename) public function getObjectManager() { if (!$this->_objectManager) { - $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); - $this->_objectManager = $objectManagerFactory->create($_SERVER); + $objectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory( + BP, + $this->_initArguments + ); + $this->_objectManager = $objectManagerFactory->create($this->_initArguments); $this->_objectManager->get('Magento\Framework\App\State')->setAreaCode(self::AREA_CODE); } return $this->_objectManager; diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php index 0b039619016a6..0572b043a8c5a 100644 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php +++ b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Config.php @@ -15,13 +15,6 @@ class Config */ protected $_config = []; - /** - * Labels for config values - * - * @var array - */ - protected $_labels = []; - /** * Get config instance * @@ -52,32 +45,6 @@ public function loadConfig($filename) $this->_config = (new \Magento\Framework\Xml\Parser())->load($filename)->xmlToArray(); } - /** - * Load labels - * - * @param string $filename - * @throws \Exception - * - * @return void - */ - public function loadLabels($filename) - { - if (!is_readable($filename)) { - throw new \Exception("Labels file `{$filename}` is not readable or does not exists."); - } - $this->_labels = (new \Magento\Framework\Xml\Parser())->load($filename)->xmlToArray(); - } - - /** - * Get labels array - * - * @return array - */ - public function getLabels() - { - return isset($this->_labels['config']['labels']) ? $this->_labels['config']['labels'] : []; - } - /** * Get profile configuration value * diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php new file mode 100644 index 0000000000000..9a6a1a7e3d4fc --- /dev/null +++ b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/Fixture.php @@ -0,0 +1,63 @@ +application = $application; + } + + /** + * Execute fixture + * + * @return void + */ + abstract public function execute(); + + /** + * Get fixture action description + * + * @return string + */ + abstract public function getActionTitle(); + + /** + * Introduce parameters labels + * + * @return array + */ + abstract public function introduceParamLabels(); + + /** + * Get fixture priority + * + * @return int + */ + public function getPriority() + { + return $this->priority; + } +} diff --git a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/FixtureSet.php b/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/FixtureSet.php deleted file mode 100644 index 5bcdb3aef8939..0000000000000 --- a/dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/FixtureSet.php +++ /dev/null @@ -1,57 +0,0 @@ -_fixtures = (new \Magento\Framework\Xml\Parser())->load($filename)->xmlToArray(); - } - - /** - * Get fixtures array - * - * @param array $default - * - * @return array - */ - public function getFixtures($default = []) - { - return isset($this->_fixtures['fixtures']) ? $this->_fixtures['fixtures'] : $default; - } -} diff --git a/dev/tools/performance-toolkit/framework/fixtures.xml b/dev/tools/performance-toolkit/framework/fixtures.xml deleted file mode 100644 index e3ed3c78bb318..0000000000000 --- a/dev/tools/performance-toolkit/framework/fixtures.xml +++ /dev/null @@ -1,53 +0,0 @@ - - -