Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 0);
     if (!$configurablesCount) {
         return;
     }
     $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);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $simpleProductsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('simple_products', 0);
     if (!$simpleProductsCount) {
         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();
             //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];
                 }
             }
         }
     }
     $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();
 }
Пример #3
0
 /**
  * {@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)];
     };
     $pattern = ['email' => '*****@*****.**', '_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();
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $this->application->resetObjectManager();
     $cartPriceRulesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('cart_price_rules', 0);
     if (!$cartPriceRulesCount) {
         return;
     }
     $cartPriceRulesProductsFloor = \Magento\ToolkitFramework\Config::getInstance()->getValue('cart_price_rules_floor', 3);
     /** @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 $model  \Magento\SalesRule\Model\Rule*/
     $model = $this->application->getObjectManager()->get('Magento\\SalesRule\\Model\\Rule');
     //Get all websites
     $categoriesArray = [];
     $websites = $storeManager->getWebsites();
     foreach ($websites as $website) {
         //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());
                 if (count($structure) > 2) {
                     $categoriesArray[] = [$category->getId(), $website->getId()];
                 }
             }
         }
     }
     asort($categoriesArray);
     $categoriesArray = array_values($categoriesArray);
     $idField = $model->getIdFieldName();
     for ($i = 0; $i < $cartPriceRulesCount; $i++) {
         $ruleName = sprintf('Shopping Cart Price Rule %1$d', $i);
         $data = [$idField => null, 'product_ids' => '', 'name' => $ruleName, 'description' => '', 'is_active' => '1', 'website_ids' => $categoriesArray[$i % count($categoriesArray)][1], 'customer_group_ids' => [0 => '0', 1 => '1', 2 => '2', 3 => '3'], 'coupon_type' => '1', 'coupon_code' => '', 'uses_per_customer' => '', 'from_date' => '', 'to_date' => '', 'sort_order' => '', 'is_rss' => '1', 'rule' => ['conditions' => [1 => ['type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Combine', 'aggregator' => 'all', 'value' => '1', 'new_child' => ''], '1--1' => ['type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Address', 'attribute' => 'total_qty', 'operator' => '>=', 'value' => $cartPriceRulesProductsFloor + $i], '1--2' => ['type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Found', 'value' => '1', 'aggregator' => 'all', 'new_child' => ''], '1--2--1' => ['type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product', 'attribute' => 'category_ids', 'operator' => '==', 'value' => $categoriesArray[$i % count($categoriesArray)][0]]], 'actions' => [1 => ['type' => 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine', 'aggregator' => 'all', 'value' => '1', 'new_child' => '']]], 'simple_action' => 'by_percent', 'discount_amount' => '10', 'discount_qty' => '0', 'discount_step' => '', 'apply_to_shipping' => '0', 'simple_free_shipping' => '0', 'stop_rules_processing' => '0', 'reward_points_delta' => '', 'store_labels' => [0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '', 9 => '', 10 => '', 11 => ''], 'page' => '1', 'limit' => '20', 'in_banners' => '', 'banner_id' => ['from' => '', 'to' => ''], 'banner_name' => '', 'visible_in' => '', 'banner_is_enabled' => '', 'related_banners' => []];
         if (isset($data['simple_action']) && $data['simple_action'] == 'by_percent' && isset($data['discount_amount'])) {
             $data['discount_amount'] = min(100, $data['discount_amount']);
         }
         if (isset($data['rule']['conditions'])) {
             $data['conditions'] = $data['rule']['conditions'];
         }
         if (isset($data['rule']['actions'])) {
             $data['actions'] = $data['rule']['actions'];
         }
         unset($data['rule']);
         $model->loadPost($data);
         $useAutoGeneration = (int) (!empty($data['use_auto_generation']));
         $model->setUseAutoGeneration($useAutoGeneration);
         $model->save();
     }
 }
Пример #5
0
 public function testTest()
 {
     $fixturesArray = \Magento\ToolkitFramework\FixtureSet::getInstance()->getFixtures();
     $config = \Magento\ToolkitFramework\Config::getInstance();
     $config->loadConfig(self::$_generatorWorkingDir . '/profiles/small.xml');
     foreach ($fixturesArray as $fixture) {
         $this->applyFixture(self::$_generatorWorkingDir . '/fixtures/' . $fixture['file']);
     }
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $indexers = \Magento\ToolkitFramework\Config::getInstance()->getValue('indexers', []);
     if (!isset($indexers["indexer"]) || empty($indexers["indexer"])) {
         return;
     }
     $this->application->resetObjectManager();
     foreach ($indexers["indexer"] as $indexer) {
         $this->application->indexersStates[$indexer['id']] = $indexer['set_scheduled'] == "true";
     }
     $this->application->getObjectManager()->get('Magento\\Framework\\App\\CacheInterface')->clean([\Magento\Framework\App\Config::CACHE_TAG]);
 }
Пример #7
0
 public function testTest()
 {
     $config = \Magento\ToolkitFramework\Config::getInstance();
     $config->loadConfig(__DIR__ . '/_files/small.xml');
     /** @var \Magento\TestFramework\Application $itfApplication */
     $itfApplication = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication();
     $shell = $this->getMock('Magento\\Framework\\Shell', [], [], '', false);
     $application = new \Magento\ToolkitFramework\Application($itfApplication->getTempDir(), $shell, $itfApplication->getInitParams());
     $application->bootstrap();
     foreach ($application->loadFixtures()->getFixtures() as $fixture) {
         $fixture->execute();
     }
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $configs = \Magento\ToolkitFramework\Config::getInstance()->getValue('configs', array());
     $this->application->resetObjectManager();
     foreach ($configs['config'] as $config) {
         /**
          * @var \Magento\Framework\App\Config\Value $configData
          */
         $configData = $this->application->getObjectManager()->create('Magento\\Framework\\App\\Config\\Value');
         $configData->setPath($config['path'])->setScope($config['scope'])->setScopeId($config['scopeId'])->setValue($config['value'])->save();
     }
     $this->application->getObjectManager()->get('Magento\\Framework\\App\\CacheInterface')->clean([\Magento\Framework\App\Config::CACHE_TAG]);
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $categoriesNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories', 0);
     if (!$categoriesNumber) {
         return;
     }
     $maxNestingLevel = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories_nesting_level', 3);
     $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');
     $groups = [];
     $storeGroups = $storeManager->getGroups();
     $i = 0;
     foreach ($storeGroups as $storeGroup) {
         $parentCategoryId[$i] = $defaultParentCategoryId[$i] = $storeGroup->getRootCategoryId();
         $nestingLevel[$i] = 1;
         $nestingPath[$i] = "1/{$parentCategoryId[$i]}";
         $categoryPath[$i] = '';
         $i++;
     }
     $groupNumber = 0;
     $anchorStep = 2;
     $categoryIndex = 1;
     while ($categoryIndex <= $categoriesNumber) {
         $category->setId(null)->setUrlKey(null)->setUrlPath(null)->setName("Category {$categoryIndex}")->setParentId($parentCategoryId[$groupNumber])->setPath($nestingPath[$groupNumber])->setLevel($nestingLevel[$groupNumber])->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->save();
         $categoryIndex++;
         $categoryPath[$groupNumber] .= '/' . $category->getName();
         if ($nestingLevel[$groupNumber]++ == $maxNestingLevel) {
             $nestingLevel[$groupNumber] = 1;
             $parentCategoryId[$groupNumber] = $defaultParentCategoryId[$groupNumber];
             $nestingPath[$groupNumber] = '1';
             $categoryPath[$groupNumber] = '';
         } else {
             $parentCategoryId[$groupNumber] = $category->getId();
         }
         $nestingPath[$groupNumber] .= "/{$parentCategoryId[$groupNumber]}";
         $groupNumber++;
         if ($groupNumber == count($defaultParentCategoryId)) {
             $groupNumber = 0;
         }
     }
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $taxRatesFile = \Magento\ToolkitFramework\Config::getInstance()->getValue('tax_rates_file', null);
     if (empty($taxRatesFile)) {
         return;
     }
     $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__ . '/' . $taxRatesFile);
     $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);
 }
Пример #11
0
<?php

/**
 * 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();
$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)];
};
$pattern = ['email' => '*****@*****.**', '_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']]);
Пример #12
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $websitesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('websites', 0);
     $storeGroupsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_groups', 0);
     $storesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('store_views', 0);
     if (!$websitesCount || !$storeGroupsCount || !$storesCount) {
         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()->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);
         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);
     }
     //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);
     }
 }
Пример #13
0
 /**
  * @return void
  */
 public function testUnaccessibleConfig()
 {
     $this->setExpectedException('Exception', 'Profile configuration file `))` is not readable or does not exists.');
     \Magento\ToolkitFramework\Config::getInstance()->loadConfig('))');
 }
Пример #14
0
<?php

/**
 * 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) {
Пример #15
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $ordersCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('orders', 0);
     if ($ordersCount < 1) {
         return;
     }
     $this->application->resetObjectManager();
     $writeAdapter = $this->getConnection('write');
     $quoteTableName = $this->getTableName('quote', 'Magento\\Quote\\Model\\Resource\\Quote');
     $quoteAddressTableName = $this->getTableName('quote_address', 'Magento\\Quote\\Model\\Resource\\Quote\\Address');
     $quoteItemTableName = $this->getTableName('quote_item', 'Magento\\Quote\\Model\\Resource\\Quote\\Item');
     $quoteItemOptionTableName = $this->getTableName('quote_item_option', 'Magento\\Quote\\Model\\Resource\\Quote\\Item\\Option');
     $quotePaymentTableName = $this->getTableName('quote_payment', 'Magento\\Quote\\Model\\Resource\\Quote\\Payment');
     $quoteAddressRateTableName = $this->getTableName('quote_shipping_rate', 'Magento\\Quote\\Model\\Resource\\Quote\\Address\\Rate');
     $reportEventTableName = $this->getTableName('report_event', 'Magento\\Reports\\Model\\Resource\\Event');
     $salesOrderTableName = $this->getTableName('sales_order', 'Magento\\Sales\\Model\\Resource\\Order');
     $salesOrderAddressTableName = $this->getTableName('sales_order_address', 'Magento\\Sales\\Model\\Resource\\Order');
     $salesOrderGridTableName = $this->getTableName('sales_order_grid', 'Magento\\Sales\\Model\\Resource\\Order\\Grid');
     $salesOrderItemTableName = $this->getTableName('sales_order_item', 'Magento\\Sales\\Model\\Resource\\Order\\Item');
     $salesOrderPaymentTableName = $this->getTableName('sales_order_payment', 'Magento\\Sales\\Model\\Resource\\Order\\Payment');
     $salesOrderStatusHistoryTableName = $this->getTableName('sales_order_status_history', 'Magento\\Sales\\Model\\Resource\\Order\\Status\\History');
     $eavEntityStoreTableName = $this->getTableName('eav_entity_store', '\\Magento\\Eav\\Model\\Resource\\Entity\\Store');
     /** @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 $product \Magento\Catalog\Model\Product */
     $product = $this->application->getObjectManager()->get('Magento\\Catalog\\Model\\Product');
     $result = [];
     $stores = $storeManager->getStores();
     foreach ($stores as $store) {
         $storeId = $store->getStoreId();
         $websiteId = $store->getWebsite()->getId();
         $websiteName = $store->getWebsite()->getName();
         $groupName = $store->getGroup()->getName();
         $storeName = $store->getName();
         $storeRootCategory = $store->getRootCategoryId();
         $category->load($storeRootCategory);
         $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();
             }
             //Not use root categories
             if (trim($resultsCategoryName) != '') {
                 /** @var $productCategory \Magento\Catalog\Model\Category */
                 $productCategory = $this->application->getObjectManager()->get('Magento\\Catalog\\Model\\Category');
                 /** @var $simpleProductCollection \Magento\Catalog\Model\Resource\Product\Collection */
                 $simpleProductCollection = $this->application->getObjectManager()->create('Magento\\Catalog\\Model\\Resource\\Product\\Collection');
                 $simpleProductCollection->addStoreFilter($storeId);
                 $simpleProductCollection->addWebsiteFilter($websiteId);
                 $simpleProductCollection->addCategoryFilter($productCategory->load($resultsCategory));
                 $simpleProductCollection->getSelect()->where(" type_id = 'simple' ");
                 $simpleIds = $simpleProductCollection->getAllIds(2);
                 $simpleProductsResult = [];
                 foreach ($simpleIds as $key => $simpleId) {
                     $simpleProduct = $product->load($simpleId);
                     $simpleProductsResult[$key]['simpleProductId'] = $simpleId;
                     $simpleProductsResult[$key]['simpleProductSku'] = $simpleProduct->getSku();
                     $simpleProductsResult[$key]['simpleProductName'] = $simpleProduct->getName();
                 }
                 $result[] = [$storeId, $websiteName . '\\n' . $groupName . '\\n' . $storeName, $simpleProductsResult];
             }
         }
     }
     $productStoreId = function ($index) use($result) {
         return $result[$index % count($result)][0];
     };
     $productStoreName = function ($index) use($result) {
         return $result[$index % count($result)][1];
     };
     $simpleProductId[0] = function ($index) use($result) {
         return $result[$index % count($result)][2][0]['simpleProductId'];
     };
     $simpleProductId[1] = function ($index) use($result) {
         return $result[$index % count($result)][2][1]['simpleProductId'];
     };
     $simpleProductSku[0] = function ($index) use($result) {
         return $result[$index % count($result)][2][0]['simpleProductSku'];
     };
     $simpleProductSku[1] = function ($index) use($result) {
         return $result[$index % count($result)][2][1]['simpleProductSku'];
     };
     $simpleProductName[0] = function ($index) use($result) {
         return $result[$index % count($result)][2][0]['simpleProductName'];
     };
     $simpleProductName[1] = function ($index) use($result) {
         return $result[$index % count($result)][2][1]['simpleProductName'];
     };
     $entityId = 1;
     while ($entityId <= $ordersCount) {
         $queries = "";
         $orderNumber = 100000000 * $productStoreId($entityId) + $entityId;
         $email = 'order_' . $entityId . '@example.com';
         $firstName = 'First Name';
         $lastName = 'Last Name';
         $company = 'Company';
         $address = 'Address';
         $city = 'City';
         $state = 'Alabama';
         $country = 'US';
         $zip = '11111';
         $phone = '911';
         $time = date("Y-m-d h:i:s");
         $simpleProductIdLen[0] = strlen($simpleProductId[0]($entityId));
         $simpleProductIdLen[1] = strlen($simpleProductId[1]($entityId));
         $queries .= "INSERT INTO `{$eavEntityStoreTableName}` (`entity_store_id`, `entity_type_id`, `store_id`, `increment_prefix`, `increment_last_id`) VALUES ({$productStoreId($entityId)}, 5, {$productStoreId($entityId)}, '{$productStoreId($entityId)}', '{$orderNumber}') ON DUPLICATE KEY UPDATE `increment_last_id`='{$orderNumber}';";
         $quoteId = $entityId;
         $queries .= "INSERT INTO `{$quoteTableName}` (`entity_id`, `store_id`, `created_at`, `updated_at`, `converted_at`, `is_active`, `is_virtual`, `is_multi_shipping`, `items_count`, `items_qty`, `orig_order_id`, `store_to_base_rate`, `store_to_quote_rate`, `base_currency_code`, `store_currency_code`, `quote_currency_code`, `grand_total`, `base_grand_total`, `checkout_method`, `customer_id`, `customer_tax_class_id`, `customer_group_id`, `customer_email`, `customer_prefix`, `customer_firstname`, `customer_middlename`, `customer_lastname`, `customer_suffix`, `customer_dob`, `customer_note`, `customer_note_notify`, `customer_is_guest`, `remote_ip`, `applied_rule_ids`, `reserved_order_id`, `password_hash`, `coupon_code`, `global_currency_code`, `base_to_global_rate`, `base_to_quote_rate`, `customer_taxvat`, `customer_gender`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `is_changed`, `trigger_recollect`, `ext_shipping_info`, `is_persistent`, `gift_message_id`) VALUES ({$quoteId}, {$productStoreId($entityId)}, '{$time}', '1970-01-01 03:00:00', NULL, 0, 0, 0, 2, 2.0000, 0, 0.0000, 0.0000, 'USD', 'USD', 'USD', 25.3000, 25.3000, 'guest', NULL, 3, 0, '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, '127.0.0.1', '1', NULL, NULL, NULL, 'USD', 1.0000, 1.0000, NULL, NULL, 17.0000, 17.0000, 15.3000, 15.3000, 1, 0, NULL, 0, NULL);";
         $quoteAddressId[0] = $entityId * 2 - 1;
         $quoteAddressId[1] = $entityId * 2;
         $queries .= "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `shipping_discount_tax_compensation_amount`, `base_shipping_discount_tax_compensation_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[0]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 1, NULL, 'billing', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 0, 0, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, 0.0000, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);";
         $queries .= "INSERT INTO `{$quoteAddressTableName}` (`address_id`, `quote_id`, `created_at`, `updated_at`, `customer_id`, `save_in_address_book`, `customer_address_id`, `address_type`, `email`, `prefix`, `firstname`, `middlename`, `lastname`, `suffix`, `company`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `fax`, `same_as_billing`, `collect_shipping_rates`, `shipping_method`, `shipping_description`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `shipping_tax_amount`, `base_shipping_tax_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `customer_notes`, `applied_taxes`, `discount_description`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `base_subtotal_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `shipping_discount_tax_compensation_amount`, `base_shipping_discount_tax_compensation_amnt`, `shipping_incl_tax`, `base_shipping_incl_tax`, `free_shipping`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`, `gift_message_id`) VALUES ({$quoteAddressId[1]}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', NULL, 0, NULL, 'shipping', '{$email}', NULL, '{$firstName}', NULL, '{$lastName}', NULL, '{$company}', '{$address}', '{$city}', '{$state}', 1, '{$zip}', '{$country}', '{$phone}', NULL, 1, 0, 'flatrate_flatrate', 'Flat Rate - Fixed', 2.0000, 17.0000, 17.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 10.0000, 0.0000, 0.0000, -1.7000, -1.7000, 25.3000, 25.3000, NULL, 'a:0:{}', NULL, 0.0000, 0.0000, 17.0000, NULL, 0.0000, 0.0000, 0.0000, NULL, 10.0000, 10.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL);";
         $quoteItemId[0] = $entityId * 4 - 3;
         $quoteItemId[1] = $entityId * 4 - 2;
         $quoteItemId[2] = $entityId * 4 - 1;
         $quoteItemId[3] = $entityId * 4;
         $queries .= "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[0]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[0]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
         $queries .= "INSERT INTO `{$quoteItemTableName}` (`item_id`, `quote_id`, `created_at`, `updated_at`, `product_id`, `store_id`, `parent_item_id`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `weight`, `qty`, `price`, `base_price`, `custom_price`, `discount_percent`, `discount_amount`, `base_discount_amount`, `tax_percent`, `tax_amount`, `base_tax_amount`, `row_total`, `base_row_total`, `row_total_with_discount`, `row_weight`, `product_type`, `base_tax_before_discount`, `tax_before_discount`, `original_custom_price`, `redirect_url`, `base_cost`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `free_shipping`, `gift_message_id`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$quoteItemId[1]}, {$quoteId}, '1970-01-01 03:00:00', '1970-01-01 03:00:00', {$simpleProductId[1]($entityId)}, {$productStoreId($entityId)}, NULL, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, 1.0000, 1.0000, 8.5000, 8.5000, NULL, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 1.0000, 'simple', NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
         $quoteItemOptionId[0] = $entityId * 8 - 7;
         $quoteItemOptionId[1] = $entityId * 8 - 6;
         $quoteItemOptionId[2] = $entityId * 8 - 5;
         $quoteItemOptionId[3] = $entityId * 8 - 4;
         $quoteItemOptionId[4] = $entityId * 8 - 3;
         $quoteItemOptionId[5] = $entityId * 8 - 2;
         $quoteItemOptionId[6] = $entityId * 8 - 1;
         $quoteItemOptionId[7] = $entityId * 8;
         $queries .= "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[0]}, {$quoteItemId[0]}, {$simpleProductId[0]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}');";
         $queries .= "INSERT INTO `{$quoteItemOptionTableName}` (`option_id`, `item_id`, `product_id`, `code`, `value`) VALUES ({$quoteItemOptionId[1]}, {$quoteItemId[1]}, {$simpleProductId[1]($entityId)}, 'info_buyRequest', 'a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}');";
         $quotePaymentId = $quoteId;
         $queries .= "INSERT INTO `{$quotePaymentTableName}` (`payment_id`, `quote_id`, `created_at`, `updated_at`, `method`, `cc_type`, `cc_number_enc`, `cc_last_4`, `cc_cid_enc`, `cc_owner`, `cc_exp_month`, `cc_exp_year`, `cc_ss_owner`, `cc_ss_start_month`, `cc_ss_start_year`, `po_number`, `additional_data`, `cc_ss_issue`, `additional_information`) VALUES ({$quotePaymentId}, {$quoteId}, '{$time}', '1970-01-01 03:00:00', 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL);";
         $quoteShippingRateId = $quoteAddressId[1];
         $queries .= "INSERT INTO `{$quoteAddressRateTableName}` (`rate_id`, `address_id`, `created_at`, `updated_at`, `carrier`, `carrier_title`, `code`, `method`, `method_description`, `price`, `error_message`, `method_title`) VALUES ({$quoteShippingRateId}, {$quoteAddressId[1]}, '{$time}', '1970-01-01 03:00:00', 'flatrate', 'Flat Rate', 'flatrate_flatrate', 'flatrate', NULL, 10.0000, NULL, 'Fixed');";
         $reportEventId[0] = $quoteItemId[0];
         $reportEventId[1] = $quoteItemId[1];
         $reportEventId[2] = $quoteItemId[2];
         $reportEventId[3] = $quoteItemId[3];
         $queries .= "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[0]}, '{$time}', 4, {$simpleProductId[0]($entityId)}, 2, 1, {$productStoreId($entityId)});";
         $queries .= "INSERT INTO `{$reportEventTableName}` (`event_id`, `logged_at`, `event_type_id`, `object_id`, `subject_id`, `subtype`, `store_id`) VALUES ({$reportEventId[1]}, '{$time}', 4, {$simpleProductId[1]($entityId)}, 2, 1, {$productStoreId($entityId)});";
         $salesOrderId = $quoteId;
         $queries .= "INSERT INTO `{$salesOrderTableName}` (`entity_id`, `state`, `status`, `coupon_code`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_discount_canceled`, `base_discount_invoiced`, `base_discount_refunded`, `base_grand_total`, `base_shipping_amount`, `base_shipping_canceled`, `base_shipping_invoiced`, `base_shipping_refunded`, `base_shipping_tax_amount`, `base_shipping_tax_refunded`, `base_subtotal`, `base_subtotal_canceled`, `base_subtotal_invoiced`, `base_subtotal_refunded`, `base_tax_amount`, `base_tax_canceled`, `base_tax_invoiced`, `base_tax_refunded`, `base_to_global_rate`, `base_to_order_rate`, `base_total_canceled`, `base_total_invoiced`, `base_total_invoiced_cost`, `base_total_offline_refunded`, `base_total_online_refunded`, `base_total_paid`, `base_total_qty_ordered`, `base_total_refunded`, `discount_amount`, `discount_canceled`, `discount_invoiced`, `discount_refunded`, `grand_total`, `shipping_amount`, `shipping_canceled`, `shipping_invoiced`, `shipping_refunded`, `shipping_tax_amount`, `shipping_tax_refunded`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_canceled`, `subtotal_invoiced`, `subtotal_refunded`, `tax_amount`, `tax_canceled`, `tax_invoiced`, `tax_refunded`, `total_canceled`, `total_invoiced`, `total_offline_refunded`, `total_online_refunded`, `total_paid`, `total_qty_ordered`, `total_refunded`, `can_ship_partially`, `can_ship_partially_item`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `edit_increment`, `email_sent`, `send_email`, `forced_shipment_with_invoice`, `payment_auth_expiration`, `quote_address_id`, `quote_id`, `shipping_address_id`, `adjustment_negative`, `adjustment_positive`, `base_adjustment_negative`, `base_adjustment_positive`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `payment_authorization_amount`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `customer_dob`, `increment_id`, `applied_rule_ids`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `customer_middlename`, `customer_prefix`, `customer_suffix`, `customer_taxvat`, `discount_description`, `ext_customer_id`, `ext_order_id`, `global_currency_code`, `hold_before_state`, `hold_before_status`, `order_currency_code`, `original_increment_id`, `relation_child_id`, `relation_child_real_id`, `relation_parent_id`, `relation_parent_real_id`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `x_forwarded_for`, `customer_note`, `created_at`, `updated_at`, `total_item_count`, `customer_gender`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `shipping_discount_tax_compensation_amount`, `base_shipping_discount_tax_compensation_amnt`, `discount_tax_compensation_invoiced`, `base_discount_tax_compensation_invoiced`, `discount_tax_compensation_refunded`, `base_discount_tax_compensation_refunded`, `shipping_incl_tax`, `base_shipping_incl_tax`, `coupon_rule_name`, `gift_message_id`) VALUES ({$salesOrderId}, 'new', 'pending', NULL, '272ecb', 'Flat Rate - Fixed', 0, {$productStoreId($entityId)}, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, 1.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1.7000, NULL, NULL, NULL, 25.3000, 10.0000, NULL, NULL, NULL, 0.0000, NULL, 0.0000, 0.0000, 17.0000, NULL, NULL, NULL, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2.0000, NULL, NULL, NULL, 1, 1, 2, 0, NULL, 1, 1, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, 17.0000, 25.3000, NULL, NULL, 17.0000, 25.3000, 2.0000, NULL, {$orderNumber}, '1', 'USD', '{$email}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'USD', NULL, NULL, 'USD', NULL, NULL, NULL, NULL, NULL, '127.0.0.1', 'flatrate_flatrate', 'USD', '{$productStoreName($entityId)}', NULL, NULL, '{$time}', '{$time}', 2, NULL, 0.0000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL);";
         $salesOrderAddressId[0] = $quoteAddressId[0];
         $salesOrderAddressId[1] = $quoteAddressId[1];
         $queries .= "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[0]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'shipping', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);";
         $queries .= "INSERT INTO `{$salesOrderAddressTableName}` (`entity_id`, `parent_id`, `customer_address_id`, `quote_address_id`, `region_id`, `customer_id`, `fax`, `region`, `postcode`, `lastname`, `street`, `city`, `email`, `telephone`, `country_id`, `firstname`, `address_type`, `prefix`, `middlename`, `suffix`, `company`, `vat_id`, `vat_is_valid`, `vat_request_id`, `vat_request_date`, `vat_request_success`) VALUES ({$salesOrderAddressId[1]}, {$salesOrderId}, NULL, NULL, 1, NULL, NULL, '{$state}', '{$zip}', '{$lastName}', '{$address}', '{$city}', '{$email}', '{$phone}', '{$country}', '{$firstName}', 'billing', NULL, NULL, NULL, '{$company}', NULL, NULL, NULL, NULL, NULL);";
         $salesOrderGridId = $salesOrderId;
         $queries .= "INSERT INTO `{$salesOrderGridTableName}` (`entity_id`, `status`, `store_id`, `store_name`, `customer_id`, `base_grand_total`, `base_total_paid`, `grand_total`, `total_paid`, `increment_id`, `base_currency_code`, `order_currency_code`, `shipping_name`, `billing_name`, `created_at`, `updated_at`) VALUES ({$salesOrderGridId}, 'pending', {$productStoreId($entityId)}, '{$productStoreName($entityId)}', NULL, 25.3000, NULL, 25.3000, NULL, {$orderNumber}, 'USD', 'USD', '', '', '{$time}', NULL);";
         $salesOrderItemId[0] = $quoteItemId[0];
         $salesOrderItemId[1] = $quoteItemId[1];
         $salesOrderItemId[2] = $quoteItemId[2];
         $salesOrderItemId[3] = $quoteItemId[3];
         $queries .= "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `discount_tax_compensation_invoiced`, `base_discount_tax_compensation_invoiced`, `discount_tax_compensation_refunded`, `base_discount_tax_compensation_refunded`, `tax_canceled`, `discount_tax_compensation_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[0]}, {$salesOrderId}, NULL, {$quoteItemId[0]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[0]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[0]}:\"{$simpleProductId[0]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[0]($entityId)}', '{$simpleProductName[0]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
         $queries .= "INSERT INTO `{$salesOrderItemTableName}` (`item_id`, `order_id`, `parent_item_id`, `quote_item_id`, `store_id`, `created_at`, `updated_at`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `no_discount`, `qty_backordered`, `qty_canceled`, `qty_invoiced`, `qty_ordered`, `qty_refunded`, `qty_shipped`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `tax_invoiced`, `base_tax_invoiced`, `discount_percent`, `discount_amount`, `base_discount_amount`, `discount_invoiced`, `base_discount_invoiced`, `amount_refunded`, `base_amount_refunded`, `row_total`, `base_row_total`, `row_invoiced`, `base_row_invoiced`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `ext_order_item_id`, `locked_do_invoice`, `locked_do_ship`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `discount_tax_compensation_invoiced`, `base_discount_tax_compensation_invoiced`, `discount_tax_compensation_refunded`, `base_discount_tax_compensation_refunded`, `tax_canceled`, `discount_tax_compensation_canceled`, `tax_refunded`, `base_tax_refunded`, `discount_refunded`, `base_discount_refunded`, `free_shipping`, `gift_message_id`, `gift_message_available`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES ({$salesOrderItemId[1]}, {$salesOrderId}, NULL, {$quoteItemId[1]}, {$productStoreId($entityId)}, '{$time}', '0000-00-00 00:00:00', {$simpleProductId[1]($entityId)}, 'simple', 'a:1:{s:15:\"info_buyRequest\";a:3:{s:4:\"uenc\";s:44:\"aHR0cDovL21hZ2UyLmNvbS9jYXRlZ29yeS0xLmh0bWw,\";s:7:\"product\";s:{$simpleProductIdLen[1]}:\"{$simpleProductId[1]($entityId)}\";s:3:\"qty\";i:1;}}', 1.0000, 0, '{$simpleProductSku[1]($entityId)}', '{$simpleProductName[1]($entityId)}', NULL, '1', NULL, 0, 0, NULL, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, NULL, 8.5000, 8.5000, 10.0000, 10.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 10.0000, 0.8500, 0.8500, 0.0000, 0.0000, 0.0000, 0.0000, 8.5000, 8.5000, 0.0000, 0.0000, 1.0000, NULL, NULL, NULL, NULL, NULL, 8.5000, 8.5000, 8.5000, 8.5000, 0.0000, 0.0000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
         $salesOrderPaymentId = $salesOrderId;
         $queries .= "INSERT INTO `{$salesOrderPaymentTableName}` (`entity_id`, `parent_id`, `base_shipping_captured`, `shipping_captured`, `amount_refunded`, `base_amount_paid`, `amount_canceled`, `base_amount_authorized`, `base_amount_paid_online`, `base_amount_refunded_online`, `base_shipping_amount`, `shipping_amount`, `amount_paid`, `amount_authorized`, `base_amount_ordered`, `base_shipping_refunded`, `shipping_refunded`, `base_amount_refunded`, `amount_ordered`, `base_amount_canceled`, `quote_payment_id`, `additional_data`, `cc_exp_month`, `cc_ss_start_year`, `echeck_bank_name`, `method`, `cc_debug_request_body`, `cc_secure_verify`, `protection_eligibility`, `cc_approval`, `cc_last_4`, `cc_status_description`, `echeck_type`, `cc_debug_response_serialized`, `cc_ss_start_month`, `echeck_account_type`, `last_trans_id`, `cc_cid_status`, `cc_owner`, `cc_type`, `po_number`, `cc_exp_year`, `cc_status`, `echeck_routing_number`, `account_status`, `anet_trans_method`, `cc_debug_response_body`, `cc_ss_issue`, `echeck_account_name`, `cc_avs_status`, `cc_number_enc`, `cc_trans_id`, `address_status`, `additional_information`) VALUES ({$salesOrderPaymentId}, {$salesOrderId}, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10.0000, 10.0000, NULL, NULL, 25.3000, NULL, NULL, NULL, 25.3000, NULL, NULL, NULL, NULL, '0', NULL, 'checkmo', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'a:1:{s:53:\"a:1:{s:12:\"method_title\";s:19:\"Check / Money order\";}\";N;}');";
         $salesOrderStatusHistoryId = $salesOrderId;
         $queries .= "INSERT INTO `{$salesOrderStatusHistoryTableName}` (`entity_id`, `parent_id`, `is_customer_notified`, `is_visible_on_front`, `comment`, `status`, `created_at`, `entity_name`) VALUES ({$salesOrderStatusHistoryId}, {$salesOrderId}, 1, 0, NULL, 'pending', '{$time}', 'order');";
         $writeAdapter->multiQuery($queries);
         $entityId++;
     }
 }
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$catalogPriceRulesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('catalog_price_rules', 10);
$model = Mage::getModel('catalogrule/rule');
$category = Mage::getModel('catalog/category');
//Get all websites
$categories_array = array();
$websites = Mage::app()->getWebsites();
foreach ($websites as $website) {
    //Get all groups
    $website_groups = $website->getGroups();
    foreach ($website_groups as $website_group) {
        $website_group_root_category = $website_group->getRootCategoryId();
        $category->load($website_group_root_category);
        $categoryResource = $category->getResource();
        //Get all categories
        $results_categories = $categoryResource->getAllChildren($category);
        foreach ($results_categories as $results_category) {
            $category->load($results_category);
            $structure = explode('/', $category->getPath());
            if (count($structure) > 2) {
                $categories_array[] = array($category->getId(), $website->getId());
            }
        }
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$simpleProductsCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('simple_products', 800);
/** @var $category \Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category');
$result = array();
//Get all websites
$websites = Mage::app()->getWebsites();
foreach ($websites as $website) {
    $website_code = $website->getCode();
    //Get all groups
    $website_groups = $website->getGroups();
    foreach ($website_groups as $website_group) {
        $website_group_root_category = $website_group->getRootCategoryId();
        $category->load($website_group_root_category);
        $categoryResource = $category->getResource();
        //Get all categories
        $results_categories = $categoryResource->getAllChildren($category);
        foreach ($results_categories as $results_category) {
            $category->load($results_category);
            $structure = explode('/', $category->getPath());
            $pathSize = count($structure);
            if ($pathSize > 1) {
                $path = array();
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$cartPriceRulesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('cart_price_rules', 10);
$cartPriceRulesProductsFloor = \Magento\ToolkitFramework\Config::getInstance()->getValue('cart_price_rules_floor', 2);
$model = Mage::getModel('salesrule/rule');
$category = Mage::getModel('catalog/category');
//Get all websites
$categories_array = array();
$websites = Mage::app()->getWebsites();
foreach ($websites as $website) {
    //Get all groups
    $website_groups = $website->getGroups();
    foreach ($website_groups as $website_group) {
        $website_group_root_category = $website_group->getRootCategoryId();
        $category->load($website_group_root_category);
        $categoryResource = $category->getResource();
        //Get all categories
        $results_categories = $categoryResource->getAllChildren($category);
        foreach ($results_categories as $results_category) {
            $category->load($results_category);
            $structure = explode('/', $category->getPath());
            if (count($structure) > 2) {
                $categories_array[] = array($category->getId(), $website->getId());
            }
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$configurablesCount = \Magento\ToolkitFramework\Config::getInstance()->getValue('configurable_products', 50);
/** @var $category \Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category');
$result = array();
//Get all websites
$websites = Mage::app()->getWebsites();
foreach ($websites as $website) {
    $website_code = $website->getCode();
    //Get all groups
    $website_groups = $website->getGroups();
    foreach ($website_groups as $website_group) {
        $website_group_root_category = $website_group->getRootCategoryId();
        $category->load($website_group_root_category);
        $categoryResource = $category->getResource();
        $root_category_name = $category->getName();
        //Get all categories
        $results_categories = $categoryResource->getAllChildren($category);
        foreach ($results_categories as $results_category) {
            $category->load($results_category);
            $structure = explode('/', $category->getPath());
            $pathSize = count($structure);
            if ($pathSize > 1) {
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$categoriesNumber = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories', 30);
$maxNestingLevel = \Magento\ToolkitFramework\Config::getInstance()->getValue('categories_nesting_level', 3);
Mage::init();
/** @var $category \Mage_Catalog_Model_Category */
$category = Mage::getModel('catalog/category');
$groups = array();
$storeGroups = Mage::app()->getGroups();
$i = 0;
foreach ($storeGroups as $storeGroup) {
    $parentCategoryId[$i] = $defaultParentCategoryId[$i] = $storeGroup->getRootCategoryId();
    $nestingLevel[$i] = 1;
    $nestingPath[$i] = "1/{$parentCategoryId[$i]}";
    $categoryPath[$i] = '';
    $i++;
}
$group_number = 0;
$anchorStep = 2;
$categoryIndex = 1;
while ($categoryIndex <= $categoriesNumber) {
    $category->setId(null)->setName("Category {$categoryIndex}")->setParentId($parentCategoryId[$group_number])->setPath($nestingPath[$group_number])->setLevel($nestingLevel[$group_number])->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->save();
    $categoryIndex++;
    $categoryPath[$group_number] .= '/' . $category->getName();
Пример #21
0
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
$applicationBaseDir = (require_once __DIR__ . '/framework/bootstrap.php');
try {
    $totalStartTime = microtime(true);
    $shell = new Zend_Console_Getopt(['profile-s' => 'Profile configuration file']);
    \Magento\ToolkitFramework\Helper\Cli::setOpt($shell);
    $args = $shell->getOptions();
    if (empty($args)) {
        echo $shell->getUsageMessage();
        exit(0);
    }
    $config = \Magento\ToolkitFramework\Config::getInstance();
    $config->loadConfig(\Magento\ToolkitFramework\Helper\Cli::getOption('profile'));
    $config->loadLabels(__DIR__ . '/framework/labels.xml');
    $labels = $config->getLabels();
    echo 'Generating profile with following params:' . PHP_EOL;
    foreach ($labels as $configKey => $label) {
        echo ' |- ' . $label . ': ' . $config->getValue($configKey) . PHP_EOL;
    }
    $files = \Magento\ToolkitFramework\FixtureSet::getInstance()->getFixtures();
    $logWriter = new \Zend_Log_Writer_Stream('php://output');
    $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL));
    $logger = new \Zend_Log($logWriter);
    $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer(), $logger);
    $application = new \Magento\ToolkitFramework\Application($applicationBaseDir, $shell);
    $application->bootstrap();
    foreach ($files as $fixture) {
<?php

/**
 * {license_notice}
 *
 * @copyright   {copyright}
 * @license     {license_link}
 */
/** @var \Magento\ToolkitFramework\Application $this */
$catalogTargetRules = \Magento\ToolkitFramework\Config::getInstance()->getValue('catalog_target_rules', 2);
$isEE = Mage::helper('core')->isModuleEnabled('Enterprise_Enterprise');
if ($isEE) {
    $model = Mage::getModel('enterprise_targetrule/rule');
    $category = Mage::getModel('catalog/category');
    //Get all websites
    $categories_array = array();
    $websites = Mage::app()->getWebsites();
    foreach ($websites as $website) {
        //Get all groups
        $website_groups = $website->getGroups();
        foreach ($website_groups as $website_group) {
            $website_group_root_category = $website_group->getRootCategoryId();
            $category->load($website_group_root_category);
            $categoryResource = $category->getResource();
            //Get all categories
            $results_categories = $categoryResource->getAllChildren($category);
            foreach ($results_categories as $results_category) {
                $category->load($results_category);
                $structure = explode('/', $category->getPath());
                if (count($structure) > 2) {
                    $categories_array[] = array($category->getId(), $website->getId());