/** * @constructor * @param ObjectManager $objectManager * @param FixtureFactory $fixtureFactory * @param CatalogProductEdit $catalogProductEdit * @param ConfigurableProduct $product * @param array $configurableOptionsEditData * @param array $checkoutData [optional] */ public function __construct(ObjectManager $objectManager, FixtureFactory $fixtureFactory, CatalogProductEdit $catalogProductEdit, ConfigurableProduct $product, array $configurableOptionsEditData, array $checkoutData = []) { $this->fixtureFactory = $fixtureFactory; $this->objectManager = $objectManager; $this->catalogProductEdit = $catalogProductEdit; $this->product = $product; $this->configurableOptionsEditData = $configurableOptionsEditData; $this->currentAssignedProducts = $this->getOriginalProductAssignedProducts(); $this->currentAttributes = $this->getOriginalProductAttributes(); $this->currentConfigurableOptionsData = $this->product->getConfigurableOptions()['attributes_data']; $this->checkoutData = $checkoutData; }
/** * Prepare filter for attribute. * * @param ConfigurableProduct $product * @param string $filterLink * @return array */ protected function prepareFilter(ConfigurableProduct $product, $filterLink) { list($attributeKey, $optionKey) = explode('::', $filterLink); $attributesData = $product->getConfigurableOptions()['attributes_data']; return ['attribute' => $attributesData[$attributeKey]['frontend_label'], 'option' => $attributesData[$attributeKey]['options'][$optionKey]['label']]; }
/** * Prepare configurable product data. * * @param ConfigurableProduct $product * @param array $valuesIndexes * @return string */ protected function prepareConfigurableProductData(ConfigurableProduct $product, array $valuesIndexes) { $result = []; $configurableOptions = $product->getConfigurableOptions(); $configurableOptionsSource = $product->getDataFieldConfig('configurable_options')['source']; $associatedProducts = $this->splitProducts($configurableOptionsSource->getProducts()); foreach ($configurableOptions['attributes_data'] as $attributeKey => $attribute) { foreach ($attribute['options'] as $optionKey => $option) { $productId = $associatedProducts[$attributeKey . ':' . $optionKey]->getId(); $result[$productId][] = ['label' => $option['label'], 'attribute_id' => $attribute['attribute_id'], 'value_index' => $valuesIndexes[$attributeKey . ':' . $optionKey], 'is_percent' => $option['price_type'] == 'Percentage' ? 1 : 0, 'pricing_value' => $option['price']]; } } return json_encode($result, true); }