Example #1
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     $number = $this->config->getNumberVouchers();
     $this->loadDataInfile = new LoadDataInfile();
     $voucherCsv = $this->writerManager->createWriter('vouchers', 'csv');
     $voucherCodeCsv = $this->writerManager->createWriter('voucher_code', 'csv');
     $voucherAttributeCsv = $this->writerManager->createWriter('voucher_code', 'csv');
     $this->createProgressBar($number);
     for ($voucherCounter = 0; $voucherCounter < $number; $voucherCounter++) {
         $this->advanceProgressBar();
         $id = $this->getUniqueId('voucher');
         $isIndividual = $voucherCounter % 2 === 1;
         $isPercental = !$voucherCounter % 3;
         $numOrder = !$isIndividual;
         // individual vouchers are not restricted
         $code = 'code' . $id;
         if ($isIndividual) {
             $code = '';
         }
         $value = mt_rand(5, 100);
         $voucherCsv->write("{$id},Voucher #{$id},{$code},{$value},101,\\N,\\N,VOUCHER{$id},{$isIndividual},{$isPercental},{$numOrder},\\N,auto");
         $voucherAttributeCsv->write("{$id}");
         if ($isIndividual) {
             for ($i = 0; $i < $this->numberOfIndividualVoucherCodes; $i++) {
                 $code = "code-{$id}-{$i}";
                 $voucherCodeCsv->write("{$id},\\N,{$code},0");
             }
         }
     }
     $writer->write($this->loadDataInfile->get('s_emarketing_vouchers', $voucherCsv->getFileName()));
     $writer->write($this->loadDataInfile->get('s_emarketing_vouchers_attributes', $voucherAttributeCsv->getFileName()));
     $writer->write($this->loadDataInfile->get('s_emarketing_voucher_codes', $voucherCodeCsv->getFileName()));
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     $this->ids['customerNumber'] = 20002;
     $number = $this->config->getNumberCustomers();
     $this->loadDataInfile = new LoadDataInfile();
     $importCustomers = $this->writerManager->createWriter('customers', 'csv');
     $importCustomersAttributes = $this->writerManager->createWriter('customers_attributes', 'csv');
     $importCustomersBilling = $this->writerManager->createWriter('customers_billing', 'csv');
     $importCustomersBillingAttributes = $this->writerManager->createWriter('customers_billing_attributes', 'csv');
     $this->createProgressBar($number);
     for ($customerCounter = 0; $customerCounter < $number; $customerCounter++) {
         $this->advanceProgressBar();
         $id = $this->getUniqueId('customer');
         $customerNumber = $this->getUniqueId('customerNumber');
         $group = $customerCounter % 2 === 1 ? "EK" : "H";
         $sex = $customerCounter % 2 === 1 ? "mr" : "ms";
         $importCustomers->write("{$id},a256a310bc1e5db755fd392c524028a8,user_{$id}@example.org,1,0,,5,2013-01-11,2015-01-01 00:00:00,,0,,0,{$group},0,1,1,,\\N,,0,\\N");
         $importCustomersAttributes->write("{$id}");
         $importCustomersBillingAttributes->write("{$id}");
         $importCustomersBillingAttributes->write("{$id}");
         $customerAttributeValues[] = "{$id}";
         $importCustomersBilling->write("{$id}, {$id}, , , {$sex}, {$customerNumber}, {$this->generator->getRandomFirstName()}, {$this->generator->getRandomLastName()}, {$this->generator->getRandomWord()} " . rand(1, 500) . "' , " . rand(42000, 50000) . ", {$this->generator->getRandomCity()}, " . rand(9999, 99999) . ", , 2, 0, , 1992-04-03");
     }
     $writer->write($this->loadDataInfile->get('s_user', $importCustomers->getFileName()));
     $writer->write($this->loadDataInfile->get('s_user_attributes', $importCustomersAttributes->getFileName()));
     $writer->write($this->loadDataInfile->get('s_user_billingaddress', $importCustomersBilling->getFileName()));
     $writer->write($this->loadDataInfile->get('s_user_billingaddress_attributes', $importCustomersBillingAttributes->getFileName()));
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     $number = $this->config->getNumberNewsletter();
     $this->createProgressBar($number);
     $addressValues = array();
     for ($i = 0; $i < $number; $i++) {
         $this->advanceProgressBar();
         $addressId = $this->getUniqueId('addressId');
         $addressValues[] = "({$addressId}, 0, 1, 'newsletter_test_{$addressId}@shopware.de', 0, 0)";
     }
     // Recipients
     $writer->write(sprintf("INSERT IGNORE INTO `s_campaigns_mailaddresses` (`id`, `customer`, `groupID`, `email`, `lastmailing`, `lastread`) VALUES %s;", implode(",\n ", $addressValues)));
     // Newsletter group
     $writer->write("INSERT IGNORE INTO `s_campaigns_groups` (`id`, `name`) VALUES (1, 'Newsletter-Empfänger');");
     // Groups assigned to the newsletter
     $groups = array(array("EK" => 0, "H" => 0), array(1 => 0));
     $groups = serialize($groups);
     // The actual newsletter
     $writer->write("INSERT IGNORE INTO `s_campaigns_mailings` (`id`, `datum`, `groups`, `subject`, `sendermail`, `sendername`, `plaintext`,\n                `templateID`, `languageID`, `status`, `locked`, `recipients`, `read`, `clicked`, `customergroup`, `publish`)\n            VALUES (1, '2013-04-25', '{$groups}', 'Newsletter-Test', '*****@*****.**',\n                'Newsletter Absender', 0, 1, 1, 0, '2013-04-25 17:45:12', {$this->config->getNumberNewsletter()}, 0, 0, 'EK', 1\n            );");
     // Container
     $writer->write("INSERT IGNORE INTO `s_campaigns_containers` (`id`, `promotionID`, `type`, `description`, `position`)\n            VALUES (1, 1, 'ctText', 'Newsletter-Test', 1);");
     // HTML Text
     $writer->write("INSERT IGNORE INTO `s_campaigns_html` (`id`, `parentID`, `headline`, `html`, `image`, `link`, `alignment`)\n            VALUES (1, '1', 'Newsletter-Test', '<p>Hallo <strong>Welt</strong></p>', '', '', 'left');");
     // Sender Mail
     $writer->write("INSERT IGNORE INTO `s_campaigns_sender` (`email`, `name`) VALUES ('*****@*****.**', 'Newsletter Absender');");
     // Template
     $writer->write("INSERT INTO `s_campaigns_templates` (`id`, `path`, `description`) VALUES\n            (1, 'index.tpl', 'Standardtemplate'),\n            (2, 'indexh.tpl', 'Händler');");
     $this->finishProgressBar();
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     $orderCSVWriter = $this->writerManager->createWriter('order', 'csv');
     $number = $this->config->getNumberOrders();
     $this->createProgressBar($number);
     if (!$this->articleResource) {
         throw new \RuntimeException('Article resource not available');
     }
     // Force order numbers to start at 10001
     $this->ids['ordernumber'] = 1000;
     $valueData = array('orderValues' => array(), 'orderDetailValues' => array(), 'customerBillingValues' => array(), 'customerShippingValues' => array(), 'customerBillingAttributeValues' => array());
     $articleDetails = $this->articleResource->getArticleDetailsFlat();
     $totalNumberCustomers = $this->config->getNumberCustomers();
     $orderNumbers = array();
     for ($orderCounter = 0; $orderCounter < $number; $orderCounter++) {
         $id = $this->getUniqueId('order');
         $orderNumber = $this->getUniqueId('ordernumber');
         $orderNumbers[] = $orderNumber;
         $currentCustomer = rand(1, $totalNumberCustomers);
         $currentCustomerNumber = 20002 + $currentCustomer;
         // Create a large order for the first order
         $numArticles = $id === 1 ? 100 : rand(1, 4);
         $totalPrice = $numArticles * 47.9;
         $totalPricePreTax = $totalPrice / 1.19;
         // Create faster inserts by using dummy data instead of INSERT..SELECTING the data from s_user_billingaddress/shippingaddress
         $valueData['customerBillingValues'][] = "( {$currentCustomer}, {$id}, '', '', 'mr', {$currentCustomerNumber}, 'dummyFirst', 'dummyLast', 'street 1', '48153', 'Münster', '', 2, 0 )";
         $valueData['customerShippingValues'][] = "( {$currentCustomer}, {$id}, '', '', 'mr', 'dummyFirst', 'dummyLast', 'street 1', '48153', 'Münster', 2, 0)";
         $valueData['customerBillingAttributeValues'][] = "({$id}, {$id})";
         $cleared = rand(9, 21);
         $state = rand(0, 8);
         $valueData['orderValues'][] = "({$id}, {$orderNumber}, {$currentCustomer}, {$totalPrice}, {$totalPricePreTax}, 0, 0, '2012-08-30 10:15:54', {$state}, {$cleared}, 4, '', '', '', '', 1, 0, '', '', '', NULL, '', '1', 9, 'EUR', 1, 1, '217.86.205.141')";
         for ($detailCounter = 1; $detailCounter <= $numArticles; $detailCounter++) {
             $detailId = $this->getUniqueId('orderDetail');
             $articleId = $articleDetails[rand(1, $this->articleResource->getIds('article'))];
             $valueData['orderDetailValues'][] = "({$detailId}, {$id}, '{$orderNumber}', '{$articleId}', 'sw-not-real', 47.90, 1, '{$this->generator->getSentence(3)}', 1, 0, 0)";
         }
     }
     $writer->write($this->createSQL($valueData));
     $orderCSVWriter->write($orderNumbers);
     $this->finishProgressBar();
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     $number = $this->config->getNumberArticles();
     $this->loadDataInfile = new LoadDataInfile();
     $urls = $this->writerManager->createWriter('article_urls', 'csv');
     $articles = $this->writerManager->createWriter('articles', 'csv');
     $details = $this->writerManager->createWriter('articles_details', 'csv');
     $prices = $this->writerManager->createWriter('articles_price', 'csv');
     $attributes = $this->writerManager->createWriter('articles_attributes', 'csv');
     $configuratorSets = $this->writerManager->createWriter('articles_configurator_set', 'csv');
     $configuratorGroups = $this->writerManager->createWriter('articles_configurator_group_values', 'csv');
     $configuratorOptions = $this->writerManager->createWriter('articles_configurator_option_values', 'csv');
     $configuratorSetOptionRelations = $this->writerManager->createWriter('articles_configurator_set_option_relation', 'csv');
     $configuratorSetGroupRelations = $this->writerManager->createWriter('articles_configurator_set_group_relation', 'csv');
     $articleCategories = $this->writerManager->createWriter('articles_categories', 'csv');
     $articlesCategoriesRO = $this->writerManager->createWriter('s_articles_categories_ro', 'csv');
     $filterArticles = $this->writerManager->createWriter('filter_articles', 'csv');
     $articleConfiguratorRelations = $this->writerManager->createWriter('article_configurator_option_relations', 'csv');
     if ($this->config->getNumberOrders() > 0) {
         $maxDetails = $this->config->getNumberArticles() * $this->config->getMaxVariants();
         $this->articleDetailsFlat = new \SplFixedArray($maxDetails);
     }
     if (!$this->categoryResource->categoriesFlat) {
         throw new \RuntimeException('Category resource not found');
     }
     $categoriesFlat = $this->categoryResource->categoriesFlat;
     $validCategoryIds = array_filter(array_keys($categoriesFlat), function ($item) {
         return $item >= 1000000;
     });
     $categoriesPerArticle = min(count($validCategoryIds), $this->config->getCategoriesPerArticle());
     if (count($validCategoryIds) < $this->config->getCategoriesPerArticle()) {
         $this->ioService->writeln('<comment>Number of categories per article will be lower than specified</comment>');
     }
     $this->createProgressBar($number);
     $images = array();
     for ($articleCounter = 0; $articleCounter < $number; $articleCounter++) {
         $this->advanceProgressBar();
         $id = $this->getUniqueId('article');
         $createConfigurator = $id === 1 ? 1 : rand(0, 1);
         // Force the first article to be a configurator
         $createFilter = rand(0, 3);
         $urls->write("/detail/index/sArticle/{$id}");
         // Get the id of the first articleDetail in advance on order to set the main_detail_id properly
         $articleDetailId = $this->getUniqueId('articleDetail');
         $detailIDs = array($articleDetailId);
         $configuratorSetId = $createConfigurator === 1 ? $id : "NULL";
         $numberOfVariants = $createConfigurator === 1 ? rand($this->config->getMinVariants(), $this->config->getMaxVariants()) : 1;
         //            $numberOfVariants = $id === 1 ? 500 : $numberOfVariants;
         $numberOfOptions = rand(2, 4);
         $numberGroups = floor(pow($numberOfVariants, 1 / $numberOfOptions));
         if ($createConfigurator === 1) {
             $numberOfVariants = $numberOfOptions * $numberGroups;
         }
         #
         # Configurator
         #
         if ($createConfigurator) {
             $configuratorSets->write("{$id}, Test-Configurator-Set Article {$id})");
             // Create configurator groups and options
             $groups = array();
             $options = array();
             for ($g = 1; $g <= $numberGroups; $g++) {
                 $groupId = $this->getUniqueId('group');
                 $configuratorGroups->write("{$groupId}, Configurator-Group #{$groupId}, NULL, {$g}");
                 $groups[$groupId] = array();
                 // Create options for this group
                 for ($o = 1; $o <= $numberOfOptions; $o++) {
                     $optionId = $this->getUniqueId('option');
                     $configuratorOptions->write("{$optionId}, {$groupId}, Option G{$groupId}-O{$optionId}, {$o}");
                     $options[] = $optionId;
                     $groups[$groupId][] = $optionId;
                 }
             }
             /**
              * create a cartesian product of the available options in order to simply assign them to articles later
              */
             $allOptions = $this->createCartesianProduct($groups);
             // Create relations
             // set-group-relations
             foreach (array_keys($groups) as $groupId) {
                 $configuratorSetGroupRelations->write("{$id}, {$groupId}");
             }
             // set-option-relations
             foreach ($options as $optionId) {
                 $configuratorSetOptionRelations->write("{$id}, {$optionId}");
             }
         }
         shuffle($validCategoryIds);
         for ($i = 0; $i < $categoriesPerArticle; $i++) {
             $articleCategories->write("{$id}, {$validCategoryIds[$i]}");
             $categoryIds = $this->getCategoryPath($validCategoryIds[$i], $categoriesFlat);
             if (empty($categoryIds)) {
                 continue;
             }
             $last = $categoryIds[0];
             foreach ($categoryIds as $categoryId) {
                 $articlesCategoriesRO->write("{$id}, {$categoryId}, {$last}");
             }
         }
         if ($this->config->getCreateImages()) {
             throw new \Exception("Not implemented, yet");
             // Images
             for ($i = 1; $i <= $numImagesPerArticle; $i++) {
                 $mediaId = $this->getUniqueId('media');
                 $name = $physicallyCreateEachImage ? $baseName . $id : $baseName;
                 $images[] = $name;
                 $mediaValues[] = "({$mediaId}, -1, {$name}, media/image/{$name}.jpg, IMAGE, jpg, 2012-08-15 )";
                 $main = $i === 1 ? 1 : 2;
                 $articlesImgValues[] = "({$id},{$name}, {$main}, jpg, {$mediaId} )";
             }
         }
         $filterOptions = $this->config->getArticleFilterOptions();
         $filterValues = $this->config->getArticleFilterValues();
         // Filters
         $filterGroupId = 1;
         if ($createFilter === 0) {
             $filterGroupId = rand(1, $filterOptions);
             for ($option = 1; $option <= $filterOptions; $option++) {
                 $optionId = $option * $filterGroupId;
                 $valueId = rand(1, $filterValues) * $optionId;
                 $filterArticles->write("{$id}, {$valueId}");
             }
         }
         #
         # Article / -details
         #
         $articles->write("{$id}, 2, {$this->generator->getSentence(3)}, SHORT DESCRIPTION, LONG DESCRIPTION, NULL, 2012-08-15, 1, 1, 20, 0, , 2012-08-30 16:57:00, 1, 0, {$filterGroupId}, 0, 0, 0, , 0, {$articleDetailId}, NULL, NULL, {$configuratorSetId}");
         // Create article details / variants
         for ($i = 1; $i <= $numberOfVariants; $i++) {
             if ($this->config->getNumberOrders() > 0) {
                 $this->articleDetailsFlat[$articleDetailId] = "{$id}|sw-{$id}-{$i}|{$articleDetailId}";
             }
             $kind = $i === 1 ? 1 : 2;
             $details->write("{$articleDetailId}, {$id}, sw-{$id}-{$i}, , {$kind}, , 0, 1, 25, 0, 0.000, 0, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, 0.7000, 1.000, Flasche(n), 2012-06-13, 0, ");
             $prices->write("EK, 1, beliebig, {$id}, {$articleDetailId}, 47.90 , 0, 0, 0 ");
             $attributes->write("{$id}, {$articleDetailId}");
             // don't get a new id after the last detail
             if ($i < $numberOfVariants) {
                 $articleDetailId = $this->getUniqueId('articleDetail');
                 $detailIDs[] = $articleDetailId;
             }
         }
         // Set articleDetail-option relation
         if ($createConfigurator) {
             foreach ($detailIDs as $detailID) {
                 $options = array_pop($allOptions);
                 foreach ($options as $option) {
                     $articleConfiguratorRelations->write("{$detailID}, " . $option);
                 }
             }
         }
     }
     if ($this->config->getCreateImages()) {
         $this->copyImages($this->config->getImageDir(), $images, $thumbs = $this->config->getThumbnailSizes(), $useSmallImage = 1);
     }
     $writer->write($this->loadDataInfile->get('s_articles', $articles->getFileName()));
     $writer->write($this->loadDataInfile->get('s_articles_details', $details->getFileName()));
     $writer->write($this->loadDataInfile->get('s_articles_prices', $prices->getFileName()));
     $writer->write($this->loadDataInfile->get('s_articles_categories', $articleCategories->getFileName()));
     $writer->write($this->loadDataInfile->get('s_articles_categories_ro', $articlesCategoriesRO->getFileName()));
     $writer->write($this->loadDataInfile->get('s_articles_attributes', $attributes->getFileName()));
     $writer->write($this->loadDataInfile->get('s_article_configurator_sets', $configuratorSets->getFileName()));
     $writer->write($this->loadDataInfile->get('s_article_configurator_option_relations', $articleConfiguratorRelations->getFileName()));
     $writer->write($this->loadDataInfile->get('s_article_configurator_groups', $configuratorGroups->getFileName()));
     $writer->write($this->loadDataInfile->get('s_article_configurator_options', $configuratorOptions->getFileName()));
     $writer->write($this->loadDataInfile->get('s_article_configurator_set_group_relations', $configuratorSetGroupRelations->getFileName()));
     $writer->write($this->loadDataInfile->get('s_filter_articles', $filterArticles->getFileName()));
     $this->createFilterGroupSQL($writer);
     $this->finishProgressBar();
 }
Example #6
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     // Start with id 4
     $this->ids['category'] = 3;
     $this->ids['finalCats'] = 1000000;
     $this->total = $this->config->getNumberCategories();
     $this->createProgressBar($this->total);
     $this->categoriesFlat[1] = null;
     $this->categoriesFlat[3] = null;
     $germanCategory = $this->buildNestedTree($this->config->getNumberCategories());
     $thisCategory = array("id" => 1, "parent" => 'NULL', 'path' => '', "name" => 'Root', "level" => 0, "position" => 0, "left" => 1, "right" => $germanCategory['right'] + 1, "children" => array($germanCategory));
     $this->categoriesFlat[1] = $thisCategory;
     $categoryUrls = $this->writerManager->createWriter('categories', 'csv');
     $categoryURLs = array();
     $values = array();
     foreach ($this->categoriesFlat as $id => $category) {
         $this->advanceProgressBar();
         $categoryURLs[] = "/cat/index/sCategory/{$category['id']}";
         $name = isset($category['name']) ? $category['name'] : $this->generator->getRandomWord();
         $values[] = "({$category['id']}, {$category['parent']}, '{$category['path']}', '{$name}', {$id}, {$category['left']}, {$category['right']}, {$category['level']},'2012-07-30 15:24:59', '2012-07-30 15:24:59', NULL, NULL, NULL,NULL, NULL, NULL, 1, 0, 0, NULL, 0, 0, 0)";
     }
     $categoryValues = sprintf("INSERT INTO `s_categories` (`id`, `parent`, `path`, `description`, `position`, `left`, `right`, `level`, `added`, `changed`, `metakeywords`, `metadescription`, `cmsheadline`, `cmstext`, `template`, `noviewselect`, `active`, `blog`, `showfiltergroups`, `external`, `hidefilter`, `hidetop`, `mediaID`) VALUES %s ;", implode(",\n             ", $values));
     $this->finishProgressBar();
     $writer->write($categoryValues);
     $categoryUrls->write($categoryURLs);
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function create(WriterInterface $writer)
 {
     // Start with id 4
     $this->ids['category'] = 3;
     $this->ids['finalCats'] = 1000000;
     $this->total = $this->config->getNumberCategories();
     $this->createProgressBar($this->total);
     $this->categoriesFlat[1] = null;
     $this->categoriesFlat[3] = null;
     $germanCategory = $this->buildNestedTree($this->config->getNumberCategories());
     $thisCategory = array("id" => 1, "parent" => 'NULL', 'path' => '', "name" => 'Root', "level" => 0, "position" => 0, "left" => 1, "right" => $germanCategory['right'] + 1, "children" => array($germanCategory));
     $this->categoriesFlat[1] = $thisCategory;
     $categoryUrls = $this->writerManager->createWriter('categories', 'csv');
     $categoryURLs = array();
     $values = array();
     foreach ($this->categoriesFlat as $id => $category) {
         $this->advanceProgressBar();
         $categoryURLs[] = "/cat/index/sCategory/{$category['id']}";
         $name = isset($category['name']) ? $category['name'] : $this->generator->getRandomWord();
         $values[] = "({$category['id']}, {$category['parent']}, '{$category['path']}', '{$name}', {$id}, 1)";
     }
     $categoryValues = sprintf("INSERT INTO `s_categories` (`id`, `parent`, `path`, `description`, `position`, `active`) VALUES %s ;", implode(",\n             ", $values));
     $this->finishProgressBar();
     $writer->write($categoryValues);
     $categoryUrls->write($categoryURLs);
 }