Пример #1
1
 /**
  * Modification of attribute config
  *
  * @param string $attributeCode
  * @param array $attributeConfig
  * @return array
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
 {
     /** @var Product $product */
     $product = $this->locator->getProduct();
     /** @var EavAttribute $eavAttribute */
     $eavAttribute = $this->eavAttributeFactory->create()->loadByCode(Product::ENTITY, $attributeCode);
     return array_replace_recursive($attributeConfig, ['arguments' => ['data' => ['config' => ['componentType' => 'dynamicRows', 'formElement' => 'component', 'renderDefaultRecord' => false, 'itemTemplate' => 'record', 'dataScope' => '', 'dndConfig' => ['enabled' => false]]]], 'children' => ['record' => ['arguments' => ['data' => ['config' => ['componentType' => Container::NAME, 'isTemplate' => true, 'is_collection' => true, 'component' => 'Magento_Ui/js/dynamic-rows/record', 'dataScope' => '']]], 'children' => ['countryState' => ['arguments' => ['data' => ['config' => ['componentType' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/group', 'visible' => true, 'label' => __('Country/State')]]], 'children' => ['country' => ['arguments' => ['data' => ['config' => ['dataType' => Text::NAME, 'formElement' => Select::NAME, 'componentType' => Field::NAME, 'dataScope' => 'country', 'visible' => true, 'options' => $this->getCountries(), 'validation' => ['required-entry' => true]]]]], 'state' => ['arguments' => ['data' => ['config' => ['componentType' => Field::NAME, 'dataType' => Text::NAME, 'formElement' => Select::NAME, 'component' => 'Magento_Weee/js/regions-tax-select', 'dataScope' => 'state', 'options' => $this->getRegions(), 'filterBy' => ['field' => 'country'], 'caption' => '*', 'visible' => true]]]]]], 'value' => ['arguments' => ['data' => ['config' => ['componentType' => Field::NAME, 'formElement' => Input::NAME, 'dataType' => Price::NAME, 'label' => __('Tax'), 'enableLabel' => true, 'dataScope' => 'value', 'validation' => ['required-entry' => true]]]]], 'website_id' => ['arguments' => ['data' => ['config' => ['dataType' => Text::NAME, 'formElement' => Select::NAME, 'componentType' => Field::NAME, 'dataScope' => 'website_id', 'label' => __('Website'), 'visible' => $this->websiteManager->isMultiWebsites(), 'options' => $this->websiteManager->getWebsites($product, $eavAttribute)]]]], 'actionDelete' => ['arguments' => ['data' => ['config' => ['componentType' => 'actionDelete', 'dataType' => Text::NAME, 'label' => __('Action')]]]]]]]]);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $fieldCode = 'quantity_and_stock_status';
     $model = $this->locator->getProduct();
     $modelId = $model->getId();
     /** @var StockItemInterface $stockItem */
     $stockItem = $this->stockRegistry->getStockItem($modelId, $model->getStore()->getWebsiteId());
     $stockData = $modelId ? $this->getData($stockItem) : [];
     if (!empty($stockData)) {
         $data[$modelId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS] = $stockData;
     }
     if (isset($stockData['is_in_stock'])) {
         $data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode]['is_in_stock'] = (int) $stockData['is_in_stock'];
     }
     if (!empty($this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY))) {
         $minSaleQtyData = null;
         $defaultConfigValue = $this->stockConfiguration->getDefaultConfigValue(StockItemInterface::MIN_SALE_QTY);
         if (strpos($defaultConfigValue, 'a:') === 0) {
             // Set data source for dynamicRows Minimum Qty Allowed in Shopping Cart
             $minSaleQtyValue = unserialize($defaultConfigValue);
             foreach ($minSaleQtyValue as $group => $qty) {
                 $minSaleQtyData[] = [StockItemInterface::CUSTOMER_GROUP_ID => $group, StockItemInterface::MIN_SALE_QTY => $qty];
             }
         } else {
             $minSaleQtyData = $defaultConfigValue;
         }
         $path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/stock_data/min_qty_allowed_in_shopping_cart';
         $data = $this->arrayManager->set($path, $data, $minSaleQtyData);
     }
     return $data;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($this->locator->getProduct()->getTypeId() === static::PRODUCT_TYPE_GROUPED) {
         $meta = $this->arrayManager->remove(CustomOptionsModifier::GROUP_CUSTOM_OPTIONS_NAME, $meta);
     }
     return $meta;
 }
 /**
  * Add Checkbox
  *
  * @return void
  */
 protected function addCheckboxIsDownloadable()
 {
     $checkboxPath = Composite::CHILDREN_PATH . '/' . ProductAttributeInterface::CODE_IS_DOWNLOADABLE;
     $checkboxConfig['arguments']['data']['config'] = ['dataType' => Form\Element\DataType\Number::NAME, 'formElement' => Form\Element\Checkbox::NAME, 'componentType' => Form\Field::NAME, 'component' => 'Magento_Downloadable/js/components/is-downloadable-handler', 'description' => __('Is this downloadable Product?'), 'dataScope' => ProductAttributeInterface::CODE_IS_DOWNLOADABLE, 'sortOrder' => 10, 'imports' => ['disabled' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' . ProductAttributeInterface::CODE_HAS_WEIGHT], 'valueMap' => ['false' => '0', 'true' => '1'], 'samplesFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_SAMPLES, 'linksFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_LINKS];
     $hideConfig['arguments']['data']['config'] = ['dataType' => Form\Element\DataType\Number::NAME, 'formElement' => Form\Element\Hidden::NAME, 'componentType' => Form\Field::NAME, 'value' => '1', 'dataScope' => ProductAttributeInterface::CODE_IS_DOWNLOADABLE, 'sortOrder' => 10];
     $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $this->locator->getProduct()->getTypeId() === Type::TYPE_DOWNLOADABLE ? $hideConfig : $checkboxConfig);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function modifyData(array $data)
 {
     /** @var \Magento\Catalog\Api\Data\ProductInterface $product */
     $product = $this->locator->getProduct();
     $modelId = $product->getId();
     $isBundleProduct = $product->getTypeId() === Type::TYPE_CODE;
     if ($isBundleProduct && $modelId) {
         $data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS] = [];
         /** @var \Magento\Bundle\Api\Data\OptionInterface $option */
         foreach ($this->optionsRepository->getList($product->getSku()) as $option) {
             $selections = [];
             /** @var \Magento\Bundle\Api\Data\LinkInterface $productLink */
             foreach ($option->getProductLinks() as $productLink) {
                 $linkedProduct = $this->productRepository->get($productLink->getSku());
                 $integerQty = 1;
                 if ($linkedProduct->getExtensionAttributes()->getStockItem()) {
                     if ($linkedProduct->getExtensionAttributes()->getStockItem()->getIsQtyDecimal()) {
                         $integerQty = 0;
                     }
                 }
                 $selections[] = ['selection_id' => $productLink->getId(), 'option_id' => $productLink->getOptionId(), 'product_id' => $linkedProduct->getId(), 'name' => $linkedProduct->getName(), 'sku' => $linkedProduct->getSku(), 'is_default' => $productLink->getIsDefault() ? '1' : '0', 'selection_price_value' => $productLink->getPrice(), 'selection_price_type' => $productLink->getPriceType(), 'selection_qty' => (bool) $integerQty ? (int) $productLink->getQty() : $productLink->getQty(), 'selection_can_change_qty' => $productLink->getCanChangeQuantity(), 'selection_qty_is_integer' => (bool) $integerQty, 'position' => $productLink->getPosition(), 'delete' => ''];
             }
             $data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS][] = ['position' => $option->getPosition(), 'option_id' => $option->getOptionId(), 'title' => $option->getTitle(), 'default_title' => $option->getDefaultTitle(), 'type' => $option->getType(), 'required' => $option->getRequired() ? '1' : '0', 'bundle_selections' => $selections];
         }
     }
     return $data;
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CODE_PRICE_TYPE, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['disabled' => (bool) $this->locator->getProduct()->getId(), 'valueMap' => ['false' => '1', 'true' => '0'], 'validation' => ['required-entry' => false]]);
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(ProductAttributeInterface::CODE_PRICE, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['imports' => ['disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked']]);
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CODE_TAX_CLASS_ID, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['imports' => ['disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked']]);
     return $meta;
 }
Пример #7
0
 /**
  * Customize Msrp format
  *
  * @return $this
  */
 protected function customizeMsrpFormat()
 {
     $modelId = $this->locator->getProduct()->getId();
     if (isset($this->data[$modelId][self::DATA_SOURCE_DEFAULT][self::FIELD_MSRP])) {
         $this->data[$modelId][self::DATA_SOURCE_DEFAULT][self::FIELD_MSRP] = number_format($this->data[$modelId][self::DATA_SOURCE_DEFAULT][self::FIELD_MSRP], 2);
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($this->locator->getProduct()->getTypeId() === Type::TYPE_CODE) {
         $config['arguments']['data']['config'] = ['visible' => 0, 'imports' => ['visible' => null]];
         $meta['advanced_inventory_modal'] = ['children' => ['stock_data' => ['children' => ['qty' => $config, 'container_min_qty' => $config, 'container_min_sale_qty' => $config, 'container_max_sale_qty' => $config, 'is_qty_decimal' => $config, 'is_decimal_divided' => $config, 'container_backorders' => $config, 'container_deferred_stock_update' => $config, 'container_notify_stock_qty' => $config]]]];
     }
     return $meta;
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     $this->meta = $meta;
     $panelConfig['arguments']['data']['config'] = ['componentType' => Form\Fieldset::NAME, 'label' => __('Downloadable Information'), 'collapsible' => true, 'opened' => $this->locator->getProduct()->getTypeId() === Type::TYPE_DOWNLOADABLE, 'dataScope' => 'data'];
     $this->meta = $this->arrayManager->set('downloadable', $this->meta, $panelConfig);
     $this->addCheckboxIsDownloadable();
     $this->addMessageBox();
     return $this->meta;
 }
Пример #10
0
 /**
  * Modify "Price Type" fields
  *
  * @param array $meta
  * @return array
  */
 private function modifyPriceTypeFields(array $meta)
 {
     $isConfigurable = $this->locator->getProduct()->getTypeId() === ConfigurableProductType::TYPE_CODE;
     $paths = $this->arrayManager->findPaths(CustomOptionsModifier::FIELD_PRICE_TYPE_NAME, $meta, CustomOptionsModifier::GROUP_CUSTOM_OPTIONS_NAME . '/children', 'children');
     foreach ($paths as $fieldPath) {
         $meta = $this->arrayManager->merge($fieldPath . static::META_CONFIG_PATH, $meta, ['component' => 'Magento_ConfigurableProduct/js/components/custom-options-price-type', 'isConfigurable' => $isConfigurable, 'bannedOptions' => ['percent'], 'imports' => ['updateOptions' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty']]);
     }
     return $meta;
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($this->locator->getProduct()->getTypeId() === ConfigurableType::TYPE_CODE) {
         $config['arguments']['data']['config'] = ['visible' => '0', 'imports' => ['visible' => null]];
         $meta['advanced_inventory_modal'] = ['children' => ['stock_data' => ['children' => ['qty' => $config, 'container_min_qty' => $config, 'container_min_sale_qty' => $config, 'container_max_sale_qty' => $config, 'is_qty_decimal' => $config, 'is_decimal_divided' => $config, 'container_backorders' => $config, 'container_notify_stock_qty' => $config]]]];
     } else {
         $config['arguments']['data']['config'] = ['imports' => ['disabled' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty']];
         $meta['advanced_inventory_modal'] = ['children' => ['stock_data' => ['children' => ['qty' => $config]]]];
     }
     return $meta;
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function modifyMeta(array $meta)
 {
     $samplesPath = Composite::CHILDREN_PATH . '/' . Composite::CONTAINER_SAMPLES;
     $samplesContainer['arguments']['data']['config'] = ['additionalClasses' => 'admin__fieldset-section', 'componentType' => Form\Fieldset::NAME, 'label' => __('Samples'), 'dataScope' => '', 'visible' => $this->locator->getProduct()->getTypeId() === Type::TYPE_DOWNLOADABLE, 'sortOrder' => 40];
     $samplesTitle['arguments']['data']['config'] = ['componentType' => Form\Field::NAME, 'formElement' => Form\Element\Input::NAME, 'dataType' => Form\Element\DataType\Text::NAME, 'label' => __('Title'), 'dataScope' => 'product.samples_title', 'scopeLabel' => $this->storeManager->isSingleStoreMode() ? '' : '[STORE VIEW]'];
     // @codingStandardsIgnoreStart
     $informationSamples['arguments']['data']['config'] = ['componentType' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/html', 'additionalClasses' => 'admin__fieldset-note', 'content' => __('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.')];
     // @codingStandardsIgnoreEnd
     $samplesContainer = $this->arrayManager->set('children', $samplesContainer, ['samples_title' => $samplesTitle, 'sample' => $this->getDynamicRows(), 'information_samples' => $informationSamples]);
     return $this->arrayManager->set($samplesPath, $meta, $samplesContainer);
 }
 /**
  * Prepare data for stock_data fields
  *
  * @param array $data
  * @return array
  */
 protected function prepareStockData(array $data)
 {
     $productId = $this->locator->getProduct()->getId();
     $stockDataFields = ['qty_increments', 'min_qty', 'min_sale_qty', 'max_sale_qty', 'notify_stock_qty'];
     foreach ($stockDataFields as $field) {
         if (isset($data[$productId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS][$field])) {
             $data[$productId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS][$field] = (double) $data[$productId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS][$field];
         }
     }
     return $data;
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $model = $this->locator->getProduct();
     $attributeSetId = $model->getAttributeSetId();
     $parameters = ['id' => $model->getId(), 'type' => $model->getTypeId(), 'store' => $model->getStoreId()];
     $actionParameters = array_merge($parameters, ['set' => $attributeSetId]);
     $reloadParameters = array_merge($parameters, ['popup' => 1, 'componentJson' => 1, 'prev_set_id' => $attributeSetId, 'type' => $this->locator->getProduct()->getTypeId()]);
     $submitUrl = $this->urlBuilder->getUrl($this->productUrls[self::KEY_SUBMIT_URL], $actionParameters);
     $validateUrl = $this->urlBuilder->getUrl($this->productUrls[self::KEY_VALIDATE_URL], $actionParameters);
     $reloadUrl = $this->urlBuilder->getUrl($this->productUrls[self::KEY_RELOAD_URL], $reloadParameters);
     return array_replace_recursive($data, ['config' => [self::KEY_SUBMIT_URL => $submitUrl, self::KEY_VALIDATE_URL => $validateUrl, self::KEY_RELOAD_URL => $reloadUrl]]);
 }
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $modelId = $this->locator->getProduct()->getId();
     $value = '';
     if (isset($data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE])) {
         $value = $data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE];
     }
     if ('' === $value) {
         $data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE] = $this->getValueFromConfig();
         $data[$modelId][static::DATA_SOURCE_DEFAULT]['use_config_' . static::FIELD_MESSAGE_AVAILABLE] = '1';
     }
     return $data;
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($this->allowedProductTypes->isAllowedProductType($this->locator->getProduct())) {
         foreach ($this->modifiers as $modifierClass) {
             /** @var ModifierInterface $bundleModifier */
             $modifier = $this->objectManager->get($modifierClass);
             if (!$modifier instanceof ModifierInterface) {
                 throw new \InvalidArgumentException(__('Type %1 is not an instance of %2', $modifierClass, ModifierInterface::class));
             }
             $meta = $modifier->modifyMeta($meta);
         }
     }
     return $meta;
 }
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE) ?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE)) {
         if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
             $meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive($meta[$groupCode]['children'][self::CODE_GROUP_PRICE], ['children' => [ProductAttributeInterface::CODE_PRICE => ['arguments' => ['data' => ['config' => ['imports' => ['disabled' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty']]]]]]]);
         }
         if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
             $productTypeId = $this->locator->getProduct()->getTypeId();
             $visibilityConfig = $productTypeId === ConfigurableType::TYPE_CODE ? ['visible' => 0, 'disabled' => 1] : ['imports' => ['disabled' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty']];
             $meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive($meta[$groupCode]['children'][self::CODE_GROUP_PRICE], ['children' => [self::$advancedPricingButton => ['arguments' => ['data' => ['config' => $visibilityConfig]]]]]);
         }
     }
     return $meta;
 }
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if (!$this->canAddAttributes()) {
         return $meta;
     }
     $general = $this->getGeneralPanelName($meta);
     if (!isset($meta[static::GROUP_CODE])) {
         $meta[static::GROUP_CODE]['arguments']['data']['config'] = ['label' => __('Attributes'), 'collapsible' => true, 'dataScope' => self::DATA_SCOPE_PRODUCT, 'sortOrder' => $this->getNextGroupSortOrder($meta, $general, static::GROUP_SORT_ORDER), 'componentType' => Component\Form\Fieldset::NAME];
     }
     $meta[static::GROUP_CODE]['arguments']['data']['config']['component'] = 'Magento_Catalog/js/components/attributes-fieldset';
     $meta[static::GROUP_CODE]['arguments']['data']['config']['visible'] = !empty($meta[static::GROUP_CODE]['children']);
     $meta['add_attribute_modal']['arguments']['data']['config'] = ['isTemplate' => false, 'componentType' => Component\Modal::NAME, 'dataScope' => '', 'provider' => 'product_form.product_form_data_source', 'options' => ['title' => __('Add Attribute'), 'buttons' => [['text' => 'Cancel', 'class' => 'action-secondary', 'actions' => [['targetName' => '${ $.name }', 'actionName' => 'actionCancel']]], ['text' => __('Add Selected'), 'class' => 'action-primary', 'actions' => [['targetName' => '${ $.name }.product_attributes_grid', 'actionName' => 'save'], ['closeModal']]]]]];
     $meta['add_attribute_modal']['children'] = ['product_attributes_grid' => ['arguments' => ['data' => ['config' => ['component' => 'Magento_Catalog/js/components/attributes-insert-listing', 'componentType' => Component\Container::NAME, 'autoRender' => false, 'dataScope' => 'product_attributes_grid', 'externalProvider' => 'product_attributes_grid.product_attributes_grid_data_source', 'selectionsProvider' => '${ $.ns }.${ $.ns }.product_attributes_columns.ids', 'ns' => 'product_attributes_grid', 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), 'immediateUpdateBySelection' => true, 'behaviourType' => 'edit', 'externalFilterMode' => true, 'dataLinks' => ['imports' => false, 'exports' => true], 'formProvider' => 'ns = ${ $.namespace }, index = product_form', 'groupCode' => static::GROUP_CODE, 'groupName' => static::GROUP_NAME, 'groupSortOrder' => static::GROUP_SORT_ORDER, 'addAttributeUrl' => $this->urlBuilder->getUrl('catalog/product/addAttributeToTemplate'), 'productId' => $this->locator->getProduct()->getId(), 'productType' => $this->locator->getProduct()->getTypeId(), 'loading' => false, 'imports' => ['attributeSetId' => '${ $.provider }:data.product.attribute_set_id'], 'exports' => ['attributeSetId' => '${ $.externalProvider }:params.template_id']]]]]];
     return $meta;
 }
 /**
  * Adding URL rewrite checkbox to meta
  *
  * @param array $meta
  * @return array
  */
 protected function addUrlRewriteCheckbox(array $meta)
 {
     $urlPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY);
     if ($urlPath) {
         $containerPath = $this->arrayManager->slicePath($urlPath, 0, -2);
         $urlKey = $this->locator->getProduct()->getData('url_key');
         $saveRewritesHistory = $this->scopeConfig->isSetFlag(self::XML_PATH_SEO_SAVE_HISTORY, ScopeInterface::SCOPE_STORE, $this->locator->getProduct()->getStoreId());
         $meta = $this->arrayManager->merge($containerPath, $meta, ['arguments' => ['data' => ['config' => ['component' => 'Magento_Ui/js/form/components/group']]]]);
         $checkbox['arguments']['data']['config'] = ['componentType' => Field::NAME, 'formElement' => Checkbox::NAME, 'dataType' => Text::NAME, 'component' => 'Magento_CatalogUrlRewrite/js/components/url-key-handle-changes', 'valueMap' => ['false' => '', 'true' => $urlKey], 'imports' => ['handleChanges' => '${ $.provider }:data.product.' . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY], 'description' => __('Create Permanent Redirect for old URL'), 'dataScope' => 'url_key_create_redirect', 'value' => $saveRewritesHistory ? $urlKey : '', 'checked' => $saveRewritesHistory];
         $meta = $this->arrayManager->merge($urlPath . '/arguments/data/config', $meta, ['valueUpdate' => 'keyup']);
         $meta = $this->arrayManager->merge($containerPath . '/children', $meta, ['url_key_create_redirect' => $checkbox]);
         $meta = $this->arrayManager->merge($containerPath . '/arguments/data/config', $meta, ['breakLine' => true]);
     }
     return $meta;
 }
Пример #20
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $fieldCode = 'quantity_and_stock_status';
     $model = $this->locator->getProduct();
     $modelId = $model->getId();
     /** @var StockItemInterface $stockItem */
     $stockItem = $this->stockRegistry->getStockItem($modelId, $model->getStore()->getWebsiteId());
     $stockData = $modelId ? $this->getData($stockItem) : [];
     if (!empty($stockData)) {
         $data[$modelId][self::DATA_SOURCE_DEFAULT][self::STOCK_DATA_FIELDS] = $stockData;
     }
     if (isset($stockData['is_in_stock'])) {
         $data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode]['is_in_stock'] = (int) $stockData['is_in_stock'];
     }
     return $data;
 }
Пример #21
0
 /**
  * Get Code model
  *
  * @return \Magento\GoogleOptimizer\Model\Code|null
  */
 protected function getCodeModel()
 {
     if ($this->locator->getProduct()->getId()) {
         return $this->codeHelper->getCodeObjectByEntity($this->locator->getProduct());
     }
     return null;
 }
Пример #22
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->locator->getProduct();
     $productId = $product->getId();
     if (!$productId) {
         return $data;
     }
     $priceModifier = $this->getPriceModifier();
     /**
      * Set field name for modifier
      */
     $priceModifier->setData('name', 'price');
     foreach ($this->getDataScopes() as $dataScope) {
         $data[$productId]['links'][$dataScope] = [];
         foreach ($this->productLinkRepository->getList($product) as $linkItem) {
             if ($linkItem->getLinkType() !== $dataScope) {
                 continue;
             }
             /** @var \Magento\Catalog\Model\Product $linkedProduct */
             $linkedProduct = $this->productRepository->get($linkItem->getLinkedProductSku(), false, $this->locator->getStore()->getId());
             $data[$productId]['links'][$dataScope][] = $this->fillData($linkedProduct, $linkItem);
         }
         if (!empty($data[$productId]['links'][$dataScope])) {
             $dataMap = $priceModifier->prepareDataSource(['data' => ['items' => $data[$productId]['links'][$dataScope]]]);
             $data[$productId]['links'][$dataScope] = $dataMap['data']['items'];
         }
     }
     $data[$productId][self::DATA_SOURCE_DEFAULT]['current_product_id'] = $productId;
     $data[$productId][self::DATA_SOURCE_DEFAULT]['current_store_id'] = $this->locator->getStore()->getId();
     return $data;
 }
Пример #23
0
 /**
  * Get Links data
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @return array
  */
 public function getLinksData()
 {
     $linksData = [];
     if ($this->locator->getProduct()->getTypeId() !== Type::TYPE_DOWNLOADABLE) {
         return $linksData;
     }
     $links = $this->locator->getProduct()->getTypeInstance()->getLinks($this->locator->getProduct());
     /** @var LinkInterface $link */
     foreach ($links as $link) {
         $linkData = [];
         $linkData['link_id'] = $link->getId();
         $linkData['title'] = $this->escaper->escapeHtml($link->getTitle());
         $linkData['price'] = $this->getPriceValue($link->getPrice());
         $linkData['number_of_downloads'] = $link->getNumberOfDownloads();
         $linkData['is_shareable'] = $link->getIsShareable();
         $linkData['link_url'] = $link->getLinkUrl();
         $linkData['type'] = $link->getLinkType();
         $linkData['sample']['url'] = $link->getSampleUrl();
         $linkData['sample']['type'] = $link->getSampleType();
         $linkData['sort_order'] = $link->getSortOrder();
         $linkData['is_unlimited'] = $linkData['number_of_downloads'] ? '0' : '1';
         if ($this->locator->getProduct()->getStoreId()) {
             $linkData['use_default_price'] = $link->getWebsitePrice() ? '0' : '1';
             $linkData['use_default_title'] = $link->getStoreTitle() ? '0' : '1';
         }
         $linkData = $this->addLinkFile($linkData, $link);
         $linkData = $this->addSampleFile($linkData, $link);
         $linksData[] = $linkData;
     }
     return $linksData;
 }
Пример #24
0
 /**
  * Check is allow change website value for combination
  *
  * @return bool
  */
 protected function isAllowChangeWebsite()
 {
     if (!$this->isShowWebsiteColumn() || $this->locator->getProduct()->getStoreId()) {
         return false;
     }
     return true;
 }
Пример #25
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     if ($this->locator->getProduct()->getTypeId() === GroupedProductType::TYPE_CODE) {
         $meta = array_replace_recursive($meta, [static::GROUP_GROUPED => ['children' => $this->getChildren(), 'arguments' => ['data' => ['config' => ['label' => __('Grouped Products'), 'collapsible' => true, 'opened' => true, 'componentType' => Form\Fieldset::NAME, 'sortOrder' => $this->getNextGroupSortOrder($meta, static::GROUP_CONTENT, static::SORT_ORDER)]]]]]);
         $meta = $this->modifyQtyAndStockStatus($meta);
     }
     return $meta;
 }
Пример #26
0
 /**
  * Add use default checkbox to title in grid
  *
  * @param string $indexTitle
  * @return $this
  */
 protected function titleUsedDefaultInGrid($indexTitle)
 {
     if ($this->locator->getProduct()->getStoreId()) {
         $linkTitleGroupPath = $this->arrayManager->findPath('container_' . $indexTitle, $this->meta, null, 'children');
         $checkboxPath = $linkTitleGroupPath . '/children/use_default_title/arguments/data/config';
         $useDefaultConfig = ['componentType' => Form\Element\Checkbox::NAME, 'formElement' => Form\Field::NAME, 'description' => __('Use Default Value'), 'dataScope' => 'use_default_title', 'valueMap' => ['false' => '0', 'true' => '1'], 'exports' => ['checked' => '${$.parentName}.' . $indexTitle . ':disabled']];
         $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig);
     }
     return $this;
 }
Пример #27
0
 /**
  * Whether attribute can have default value
  *
  * @param ProductAttributeInterface $attribute
  * @return bool
  */
 private function canDisplayUseDefault(ProductAttributeInterface $attribute)
 {
     $attributeCode = $attribute->getAttributeCode();
     /** @var Product $product */
     $product = $this->locator->getProduct();
     if (isset($this->canDisplayUseDefault[$attributeCode])) {
         return $this->canDisplayUseDefault[$attributeCode];
     }
     return $this->canDisplayUseDefault[$attributeCode] = $attribute->getScope() != ProductAttributeInterface::SCOPE_GLOBAL_TEXT && $product && $product->getId() && $product->getStoreId();
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function modifyMeta(array $meta)
 {
     if ($groupCode = $this->getGroupCodeByField($meta, ProductAttributeInterface::CODE_PRICE) ?: $this->getGroupCodeByField($meta, self::CODE_GROUP_PRICE)) {
         $isNewProduct = $this->locator->getProduct()->getId() ? false : true;
         $pricePath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_PRICE) ?: $this->getElementArrayPath($meta, self::CODE_GROUP_PRICE);
         $meta[$groupCode]['children'][self::CODE_PRICE_TYPE] = ['arguments' => ['data' => ['config' => ['sortOrder' => self::SORT_ORDER, 'formElement' => Form\Element\Checkbox::NAME, 'componentType' => Form\Field::NAME, 'label' => __('Dynamic Price'), 'prefer' => 'toggle', 'additionalClasses' => 'admin__field-x-small', 'templates' => ['checkbox' => 'ui/form/components/single/switcher'], 'valueMap' => ['false' => '1', 'true' => '0'], 'dataScope' => self::CODE_PRICE_TYPE, 'value' => '0', 'disabled' => $isNewProduct ? false : true, 'scopeLabel' => $this->arrayManager->get($pricePath . '/scopeLabel', $meta)]]]];
         if (!empty($meta[$groupCode]['children']['container_' . self::CODE_PRICE_TYPE])) {
             $container =& $meta[$groupCode]['children']['container_' . self::CODE_PRICE_TYPE];
             $container['arguments']['data']['config']['sortOrder'] = self::SORT_ORDER;
             $container['arguments']['data']['config']['label'] = __('Dynamic Price');
         }
         if (!empty($meta[$groupCode]['children'][self::CODE_GROUP_PRICE])) {
             $meta[$groupCode]['children'][self::CODE_GROUP_PRICE] = array_replace_recursive($meta[$groupCode]['children'][self::CODE_GROUP_PRICE], ['children' => [ProductAttributeInterface::CODE_PRICE => ['arguments' => ['data' => ['config' => ['imports' => ['disabled' => 'ns = ${ $.ns }, index = ' . self::CODE_PRICE_TYPE . ':checked']]]]]]]);
         }
         if (!empty($meta[$groupCode]['children']['container_' . self::CODE_TAX_CLASS_ID])) {
             $meta[$groupCode]['children']['container_' . self::CODE_TAX_CLASS_ID] = array_replace_recursive($meta[$groupCode]['children']['container_' . self::CODE_TAX_CLASS_ID], ['children' => [self::CODE_TAX_CLASS_ID => ['arguments' => ['data' => ['config' => ['imports' => ['disabled' => 'ns = ${ $.ns }, index = ' . self::CODE_PRICE_TYPE . ':checked']]]]]]]);
         }
     }
     return $meta;
 }
Пример #29
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function modifyMeta(array $meta)
 {
     $linksPath = Composite::CHILDREN_PATH . '/' . Composite::CONTAINER_LINKS;
     $linksContainer['arguments']['data']['config'] = ['componentType' => Form\Fieldset::NAME, 'additionalClasses' => 'admin__fieldset-section', 'label' => __('Links'), 'dataScope' => '', 'visible' => $this->locator->getProduct()->getTypeId() === Type::TYPE_DOWNLOADABLE, 'sortOrder' => 30];
     $linksTitle['arguments']['data']['config'] = ['componentType' => Form\Field::NAME, 'formElement' => Form\Element\Input::NAME, 'dataType' => Form\Element\DataType\Text::NAME, 'label' => __('Title'), 'dataScope' => 'product.links_title', 'scopeLabel' => $this->storeManager->isSingleStoreMode() ? '' : '[STORE VIEW]'];
     $linksPurchasedSeparately['arguments']['data']['config'] = ['componentType' => Form\Field::NAME, 'formElement' => Form\Element\Checkbox::NAME, 'dataType' => Form\Element\DataType\Number::NAME, 'description' => __('Links can be purchased separately'), 'label' => ' ', 'dataScope' => 'product.links_purchased_separately', 'scopeLabel' => $this->storeManager->isSingleStoreMode() ? '' : '[GLOBAL]', 'valueMap' => ['false' => '0', 'true' => '1']];
     // @codingStandardsIgnoreStart
     $informationLinks['arguments']['data']['config'] = ['componentType' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/html', 'additionalClasses' => 'admin__fieldset-note', 'content' => __('Alphanumeric, dash and underscore characters are recommended for filenames. Improper characters are replaced with \'_\'.')];
     // @codingStandardsIgnoreEnd
     $linksContainer = $this->arrayManager->set('children', $linksContainer, ['links_title' => $linksTitle, 'links_purchased_separately' => $linksPurchasedSeparately, 'link' => $this->getDynamicRows(), 'information_links' => $informationLinks]);
     return $this->arrayManager->set($linksPath, $meta, $linksContainer);
 }
 /**
  * Add links for fields depends of product name
  *
  * @param array $meta
  * @return array
  */
 protected function customizeNameListeners(array $meta)
 {
     $listeners = [ProductAttributeInterface::CODE_SKU, ProductAttributeInterface::CODE_SEO_FIELD_META_TITLE, ProductAttributeInterface::CODE_SEO_FIELD_META_KEYWORD, ProductAttributeInterface::CODE_SEO_FIELD_META_DESCRIPTION];
     foreach ($listeners as $listener) {
         $listenerPath = $this->getElementArrayPath($meta, $listener);
         $importsConfig = ['arguments' => ['data' => ['config' => ['component' => 'Magento_Catalog/js/components/import-handler', 'imports' => ['handleChanges' => '${$.provider}:data.product.name']]]]];
         $meta = $this->arrayManager->merge($listenerPath, $meta, $importsConfig);
     }
     $skuPath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_SKU);
     $meta = $this->arrayManager->merge($skuPath, $meta, ['arguments' => ['data' => ['config' => ['autoImportIfEmpty' => true, 'allowImport' => $this->locator->getProduct()->getId() ? false : true]]]]);
     $namePath = $this->getElementArrayPath($meta, ProductAttributeInterface::CODE_NAME);
     return $this->arrayManager->merge($namePath, $meta, ['arguments' => ['data' => ['config' => ['valueUpdate' => 'keyup']]]]);
 }