Esempio n. 1
0
 /**
  * Get pattern object
  *
  * @param array $patternData
  *
  * @return \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern
  */
 protected function getPattern($patternData)
 {
     $pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern();
     $pattern->setHeaders(array_keys($patternData[0]));
     $pattern->setRowsSet($patternData);
     return $pattern;
 }
            }
        }
    }
}
$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];
};
$headers = array('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', 'media_gallery', 'meta_description', 'meta_keyword', 'meta_title', 'minimal_price', 'msrp', 'msrp_display_actual_price_type', 'msrp_enabled', 'name', 'news_from_date', 'news_to_date', 'options_container', 'page_layout', 'price', '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', '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', 'stock_status_changed_auto', 'use_config_qty_increments', 'qty_increments', 'use_config_enable_qty_inc', 'enable_qty_increments', 'is_decimal_divided', '_links_related_sku', '_links_related_position', '_links_crosssell_sku', '_links_crosssell_position', '_links_upsell_sku', '_links_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_lable', '_media_position', '_media_is_disabled', '_super_products_sku', '_super_attribute_code', '_super_attribute_option', '_super_attribute_price_corr');
$rows = array(array('sku' => 'config_option_%s_1_sku', '_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' => '2014-01-16 11:00:35', 'custom_design' => '', 'custom_design_from' => '', 'custom_design_to' => '', 'custom_layout_update' => '', 'description' => 'Configurable %s option 1 desc', 'enable_googlecheckout' => '1', 'gallery' => '', 'gift_message_available' => '', 'gift_wrapping_available' => '', 'gift_wrapping_price' => '', 'has_options' => '0', 'image' => 'no_selection', 'image_label' => '', 'is_returnable' => 'Use config', 'manufacturer' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => 'Use config', 'msrp_enabled' => 'Use config', 'name' => 'Configurable option 1', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => 'Block after Info Column', 'page_layout' => '', 'price' => '50.0000', 'related_tgtr_position_behavior' => '', 'related_tgtr_position_limit' => '', 'required_options' => '0', 'short_description' => 'Configurable %s option 1 short desc', 'small_image' => 'no_selection', 'small_image_label' => '', 'special_from_date' => '', 'special_price' => '', 'special_to_date' => '', 'status' => '1', 'tax_class_id' => '0', 'thumbnail' => 'no_selection', 'thumbnail_label' => '', 'updated_at' => '2014-01-16 11:13:29', 'upsell_tgtr_position_behavior' => '', 'upsell_tgtr_position_limit' => '', 'url_key' => 'configurable-option-%s-1', 'url_path' => 'configurable-option-%s-1.html', 'visibility' => '1', 'weight' => '10.0000', 'qty' => '100500.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' => '0', 'stock_status_changed_auto' => '0', 'use_config_qty_increments' => '1', 'qty_increments' => '0.0000', 'use_config_enable_qty_inc' => '1', 'enable_qty_increments' => '0', 'is_decimal_divided' => '0', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => '', '_super_attribute_code' => '', '_super_attribute_option' => '', '_super_attribute_price_corr' => ''), array('sku' => 'config_option_%s_2_sku', '_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' => '2014-01-16 11:02:00', 'custom_design' => '', 'custom_design_from' => '', 'custom_design_to' => '', 'custom_layout_update' => '', 'description' => 'Configurable %s option 1 desc', 'enable_googlecheckout' => '1', 'gallery' => '', 'gift_message_available' => '', 'gift_wrapping_available' => '', 'gift_wrapping_price' => '', 'has_options' => '0', 'image' => 'no_selection', 'image_label' => '', 'is_returnable' => 'Use config', 'manufacturer' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => 'Use config', 'msrp_enabled' => 'Use config', 'name' => 'Configurable option 2', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => 'Block after Info Column', 'page_layout' => '', 'price' => '200.0000', 'related_tgtr_position_behavior' => '', 'related_tgtr_position_limit' => '', 'required_options' => '0', 'short_description' => 'Configurable %s option 1 short desc', 'small_image' => 'no_selection', 'small_image_label' => '', 'special_from_date' => '', 'special_price' => '', 'special_to_date' => '', 'status' => '1', 'tax_class_id' => '0', 'thumbnail' => 'no_selection', 'thumbnail_label' => '', 'updated_at' => '2014-01-16 11:11:30', 'upsell_tgtr_position_behavior' => '', 'upsell_tgtr_position_limit' => '', 'url_key' => 'configurable-option-%s-2', 'url_path' => 'configurable-option-%s-2.html', 'visibility' => '1', 'weight' => '111.0000', 'qty' => '100500.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' => '0', 'stock_status_changed_auto' => '0', 'use_config_qty_increments' => '1', 'qty_increments' => '0.0000', 'use_config_enable_qty_inc' => '1', 'enable_qty_increments' => '0', 'is_decimal_divided' => '0', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => '', '_super_attribute_code' => '', '_super_attribute_option' => '', '_super_attribute_price_corr' => ''), array('sku' => 'config_option_%s_3_sku', '_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' => '2014-01-16 11:03:25', 'custom_design' => '', 'custom_design_from' => '', 'custom_design_to' => '', 'custom_layout_update' => '', 'description' => 'Configurable %s option 1 desc', 'enable_googlecheckout' => '1', 'gallery' => '', 'gift_message_available' => '', 'gift_wrapping_available' => '', 'gift_wrapping_price' => '', 'has_options' => '0', 'image' => 'no_selection', 'image_label' => '', 'is_returnable' => 'Use config', 'manufacturer' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => 'Use config', 'msrp_enabled' => 'Use config', 'name' => 'Configurable option 3', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => 'Block after Info Column', 'page_layout' => '', 'price' => '111.0000', 'related_tgtr_position_behavior' => '', 'related_tgtr_position_limit' => '', 'required_options' => '0', 'short_description' => 'Configurable %s option 1 short desc', 'small_image' => 'no_selection', 'small_image_label' => '', 'special_from_date' => '', 'special_price' => '', 'special_to_date' => '', 'status' => '1', 'tax_class_id' => '0', 'thumbnail' => 'no_selection', 'thumbnail_label' => '', 'updated_at' => '2014-01-16 11:12:27', 'upsell_tgtr_position_behavior' => '', 'upsell_tgtr_position_limit' => '', 'url_key' => 'configurable-option-%s-3', 'url_path' => 'configurable-option-%s-3.html', 'visibility' => '1', 'weight' => '111.0000', 'qty' => '100500.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' => '0', 'stock_status_changed_auto' => '0', 'use_config_qty_increments' => '1', 'qty_increments' => '0.0000', 'use_config_enable_qty_inc' => '1', 'enable_qty_increments' => '0', 'is_decimal_divided' => '0', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => '', '_super_attribute_code' => '', '_super_attribute_option' => '', '_super_attribute_price_corr' => ''), array('sku' => 'config_%s_sku', '_store' => '', '_attribute_set' => 'Default', '_type' => 'configurable', '_category' => $productCategory, '_root_category' => $productRootCategory, '_product_websites' => $productWebsite, 'color' => '', 'configurable_variations' => '', 'cost' => '', 'country_of_manufacture' => '', 'created_at' => '2014-01-16 11:03:40', 'custom_design' => '', 'custom_design_from' => '', 'custom_design_to' => '', 'custom_layout_update' => '', 'description' => 'Description %s', 'enable_googlecheckout' => '1', 'gallery' => '', 'gift_message_available' => '', 'gift_wrapping_available' => '', 'gift_wrapping_price' => '', 'has_options' => '1', 'image' => 'no_selection', 'image_label' => '', 'is_returnable' => 'Use config', 'manufacturer' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => 'Use config', 'msrp_enabled' => 'Use config', 'name' => 'Configurable Product %s', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => 'Block after Info Column', 'page_layout' => '', 'price' => '100.0000', 'related_tgtr_position_behavior' => '', 'related_tgtr_position_limit' => '', 'required_options' => '1', 'short_description' => 'Short Description %s', 'small_image' => 'no_selection', 'small_image_label' => '', 'special_from_date' => '', 'special_price' => '', 'special_to_date' => '', 'status' => '1', 'tax_class_id' => '0', 'thumbnail' => 'no_selection', 'thumbnail_label' => '', 'updated_at' => '2014-01-16 11:04:56', 'upsell_tgtr_position_behavior' => '', 'upsell_tgtr_position_limit' => '', 'url_key' => 'configurable-product-%s', 'url_path' => 'configurable-product-%s.html', 'visibility' => '4', 'weight' => '', 'qty' => '0.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' => '0', 'stock_status_changed_auto' => '0', 'use_config_qty_increments' => '1', 'qty_increments' => '0.0000', 'use_config_enable_qty_inc' => '1', 'enable_qty_increments' => '0', 'is_decimal_divided' => '0', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => 'config_option_%s_1_sku', '_super_attribute_code' => 'configurable_variations', '_super_attribute_option' => 'option 1', '_super_attribute_price_corr' => '10.0000'), array('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' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => '', 'msrp_enabled' => '', 'name' => '', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => '', 'page_layout' => '', 'price' => '', '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' => '', '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' => '', 'stock_status_changed_auto' => '', 'use_config_qty_increments' => '', 'qty_increments' => '', 'use_config_enable_qty_inc' => '', 'enable_qty_increments' => '', 'is_decimal_divided' => '', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => 'config_option_%s_2_sku', '_super_attribute_code' => 'configurable_variations', '_super_attribute_option' => 'option 2', '_super_attribute_price_corr' => '20.0000'), array('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' => '', 'media_gallery' => '', 'meta_description' => '', 'meta_keyword' => '', 'meta_title' => '', 'minimal_price' => '', 'msrp' => '', 'msrp_display_actual_price_type' => '', 'msrp_enabled' => '', 'name' => '', 'news_from_date' => '', 'news_to_date' => '', 'options_container' => '', 'page_layout' => '', 'price' => '', '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' => '', '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' => '', 'stock_status_changed_auto' => '', 'use_config_qty_increments' => '', 'qty_increments' => '', 'use_config_enable_qty_inc' => '', 'enable_qty_increments' => '', 'is_decimal_divided' => '', '_links_related_sku' => '', '_links_related_position' => '', '_links_crosssell_sku' => '', '_links_crosssell_position' => '', '_links_upsell_sku' => '', '_links_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_lable' => '', '_media_position' => '', '_media_is_disabled' => '', '_super_products_sku' => 'config_option_%s_3_sku', '_super_attribute_code' => 'configurable_variations', '_super_attribute_option' => 'option 3', '_super_attribute_price_corr' => '30.0000'));
/**
 * Create configurable products
 */
$pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern();
$pattern->setHeaders($headers);
$pattern->setRowsSet($rows);
/** @var \Mage_ImportExport_Model_Import $import */
$import = Mage::getModel('importexport/import');
$import->setEntity('catalog_product');
$import->setBehavior('append');
$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((string) $source);
// this converts import queue into actual entities
$import->importSource();
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 0);
     if (!$configurablesCount) {
         return;
     }
     $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];
                 }
             }
         }
     }
     $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];
     };
     /**
      * Create configurable products
      */
     $pattern = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Pattern();
     $pattern->setHeaders($this->getHeaders());
     $pattern->setRowsSet($this->getRows($productCategory, $productRootCategory, $productWebsite));
     /** @var \Magento\ImportExport\Model\Import $import */
     $import = $this->application->getObjectManager()->create('Magento\\ImportExport\\Model\\Import', ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']]);
     $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();
 }