Exemple #1
0
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->fixtureFactory = $fixtureFactory;
     $this->params = $params;
     $this->data = $data;
     if (isset($data['widget']['dataset']) && isset($this->params['repository'])) {
         $this->data['widget']['dataset'] = $repositoryFactory->get($this->params['repository'])->get($data['widget']['dataset']);
         foreach ($this->data['widget']['dataset'] as $key => $widget) {
             if (isset($widget['chosen_option']['category_path']) && !isset($widget['chosen_option']['filter_sku'])) {
                 $category = $this->createCategory($widget);
                 $categoryName = $category->getData('name');
                 $this->data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName;
             }
             if (isset($widget['chosen_option']['category_path']) && isset($widget['chosen_option']['filter_sku'])) {
                 $product = $this->createProduct($widget);
                 $categoryName = $product->getCategoryIds()[0]['name'];
                 $productSku = $product->getData('sku');
                 $this->data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName;
                 $this->data['widget']['dataset'][$key]['chosen_option']['filter_sku'] = $productSku;
             }
             if ($widget['widget_type'] == 'Catalog New Products List') {
                 $this->createProduct();
             }
             if ($widget['widget_type'] == 'CMS Static Block') {
                 $block = $this->createBlock($widget);
                 $blockIdentifier = $block->getIdentifier();
                 $this->data['widget']['dataset'][$key]['chosen_option']['filter_identifier'] = $blockIdentifier;
             }
         }
     }
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory|null $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data)
 {
     $this->params = $params;
     $this->data = !isset($data['dataset']) && !isset($data['import_products']) ? $data : [];
     $this->customOptions = $this->data;
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         $this->data = $this->replaceData($this->data, mt_rand());
         $this->customOptions = $this->data;
     }
     if (isset($data['import_products'])) {
         $importData = explode(',', $data['import_products']);
         $importCustomOptions = [];
         $importProducts = [];
         foreach ($importData as $item) {
             list($fixture, $dataset) = explode('::', $item);
             $product = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
             if ($product->hasData('id') !== null) {
                 $product->persist();
             }
             $importCustomOptions = array_merge($importCustomOptions, $product->getCustomOptions());
             $importProducts[] = $product->getSku();
         }
         $this->customOptions = array_merge($this->data, $importCustomOptions);
         $this->data['import'] = ['options' => $importCustomOptions, 'products' => $importProducts];
     }
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $datasets = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         foreach ($datasets as $dataset) {
             list($fixtureCode, $dataset) = explode('::', $dataset);
             $this->products[] = $fixtureFactory->createByCode($fixtureCode, ['dataset' => $dataset]);
         }
     }
     if (isset($data['products'])) {
         foreach ($data['products'] as $product) {
             $this->products[] = $product;
         }
     }
     foreach ($this->products as $product) {
         if (!$product->hasData('id')) {
             $product->persist();
         }
         $this->data[] = ['entity_id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
     }
     if (isset($data['data'])) {
         $this->data = array_replace_recursive($this->data, $data['data']);
     }
 }
Exemple #4
0
 /**
  * Prepare source data.
  *
  * @return void
  */
 protected function prepareSourceData()
 {
     if (isset($this->data['widget']['dataset']) && isset($this->params['repository'])) {
         $this->data['widget']['dataset'] = $this->repositoryFactory->get($this->params['repository'])->get($this->data['widget']['dataset']);
         $this->data = array_merge($this->data, $this->prepareWidgetData($this->data['widget']));
     }
 }
Exemple #5
0
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(RepositoryFactory $repositoryFactory, array $params, $data = [])
 {
     $this->params = $params;
     $this->data = !isset($data['dataset']) && !isset($data['value']) ? $data : null;
     if (isset($data['value'])) {
         $this->data = $data['value'];
     }
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $this->priceData = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
     }
 }
Exemple #6
0
 /**
  * Return prepared data set.
  *
  * @param string $key [optional]
  * @return mixed
  * @throws \Exception
  */
 public function getData($key = null)
 {
     if (!isset($this->fixtureData['dataset'])) {
         throw new \Exception("Data must be set");
     }
     $this->data = $this->repositoryFactory->get($this->params['repository'])->get($this->fixtureData['dataset']);
     foreach ($this->data as $key => $item) {
         /** @var CustomerGroup $customerGroup */
         $customerGroup = $this->fixtureFactory->createByCode('customerGroup', ['dataset' => $item['customer_group']['dataset']]);
         if (!$customerGroup->hasData('customer_group_id')) {
             $customerGroup->persist();
         }
         $this->data[$key]['customer_group'] = $customerGroup->getCustomerGroupCode();
         $this->customerGroups[$key] = $customerGroup;
     }
     return parent::getData($key);
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         foreach ($this->data as $index => $layouts) {
             if (isset($layouts['entities'])) {
                 $explodeValue = explode('::', $layouts['entities']);
                 $fixture = $fixtureFactory->createByCode($explodeValue[0], ['dataset' => $explodeValue[1]]);
                 $fixture->persist();
                 $this->data[$index]['entities'] = $fixture;
             }
         }
     } else {
         $this->data = $data;
     }
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $data
  * @param array $params [optional]
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $data, array $params = [])
 {
     $this->fixtureFactory = $fixtureFactory;
     $this->params = $params;
     $dataset = [];
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $dataset = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         unset($data['dataset']);
     }
     $data = array_replace_recursive($data, $dataset);
     if (!empty($data)) {
         $this->prepareAttributes($data);
         $this->prepareAttributesData($data);
         $this->prepareProducts($data);
         $this->prepareVariationsMatrix($data);
         $this->prepareData();
     }
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         if (isset($this->data['entities'])) {
             foreach ($this->data['entities'] as $index => $entity) {
                 $explodeValue = explode('::', $entity);
                 $fixture = $fixtureFactory->createByCode($explodeValue[0], ['dataset' => $explodeValue[1]]);
                 $fixture->persist();
                 $this->data['entities'][$index] = $fixture;
                 $this->entities[] = $fixture;
             }
         }
     } elseif (isset($data['entity']) && $data['entity'] instanceof FixtureInterface) {
         $this->data['entities'][] = $data['entity'];
     } else {
         $this->data = $data;
     }
 }
 /**
  * Prepare products for bundle items.
  *
  * @return void
  */
 protected function prepareProducts()
 {
     if (!empty($this->data['products'])) {
         $productsSelections = $this->data['products'];
         $this->data['products'] = [];
         foreach ($productsSelections as $index => $products) {
             $productSelection = [];
             foreach ($products as $key => $product) {
                 if ($product instanceof FixtureInterface) {
                     $productSelection[$key] = $product;
                     continue;
                 }
                 list($fixture, $dataset) = explode('::', $product);
                 $productSelection[$key] = $this->fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
                 $productSelection[$key]->persist();
                 $this->data['bundle_options'][$index]['assigned_products'][$key]['search_data']['name'] = $productSelection[$key]->getName();
             }
             $this->data['products'][] = $productSelection;
         }
     }
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $data
  * @param array $params [optional]
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $data, array $params = [])
 {
     $this->params = $params;
     $this->data = isset($data['dataset']) ? $repositoryFactory->get($this->params['repository'])->get($data['dataset']) : $data;
     $this->data['products'] = isset($data['products']) && !is_array($data['products']) ? explode(',', $data['products']) : $this->data['products'];
     foreach ($this->data['products'] as $key => $product) {
         if (!$product instanceof FixtureInterface) {
             list($fixture, $dataset) = explode('::', $product);
             /** @var $productFixture InjectableFixture */
             $product = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
         }
         if (!$product->hasData('id')) {
             $product->persist();
         }
         $this->data['products'][$key] = $product;
     }
     $assignedProducts =& $this->data['assigned_products'];
     foreach (array_keys($assignedProducts) as $key) {
         $assignedProducts[$key]['name'] = $this->data['products'][$key]->getName();
         $assignedProducts[$key]['id'] = $this->data['products'][$key]->getId();
         $assignedProducts[$key]['position'] = $key + 1;
     }
 }