Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CODE_WEIGHT_TYPE, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['valueMap' => ['false' => '1', 'true' => '0'], 'validation' => ['required-entry' => false]]);
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(ProductAttributeInterface::CODE_HAS_WEIGHT, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['disabled' => true, 'visible' => false]);
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(ProductAttributeInterface::CODE_WEIGHT, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['imports' => ['disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_WEIGHT_TYPE . ':checked']]);
     return $meta;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $product = $this->locator->getProduct();
     if ($product->getTypeId() === static::PRODUCT_TYPE_GROUPED) {
         $data = $this->arrayManager->remove($this->arrayManager->findPath(CustomOptionsModifier::FIELD_ENABLE, $data), $data);
     }
     return $data;
 }
Exemplo n.º 4
0
 /**
  * Add warning over options grid
  *
  * @param array $meta
  * @return array
  */
 private function addPriceTypeWarning(array $meta)
 {
     $gridPath = $this->arrayManager->findPath(CustomOptionsModifier::GRID_OPTIONS_NAME, $meta, CustomOptionsModifier::GROUP_CUSTOM_OPTIONS_NAME . '/children', 'children');
     if ($gridPath) {
         $path = $this->arrayManager->slicePath($gridPath, 0, -1) . '/' . static::WARNING_PRICE_TYPE;
         $sortOrder = $this->arrayManager->get($gridPath . static::META_CONFIG_PATH . '/sortOrder', $meta) - 1;
         $isConfigurable = $this->locator->getProduct()->getTypeId() === ConfigurableProductType::TYPE_CODE;
         $meta = $this->arrayManager->set($path . static::META_CONFIG_PATH, $meta, ['componentType' => Container::NAME, 'component' => 'Magento_ConfigurableProduct/js/components/custom-options-warning', 'additionalClasses' => 'message message-warning', 'sortOrder' => $sortOrder, 'isConfigurable' => $isConfigurable, 'content' => __('Custom options with price type "percent" is not available for configurable product.'), 'imports' => ['updateVisibility' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty']]);
     }
     return $meta;
 }
Exemplo n.º 5
0
 /**
  * Customization of allow gift message field
  *
  * @param array $meta
  * @return array
  */
 protected function customizeAllowGiftMessageField(array $meta)
 {
     $groupCode = $this->getGroupCodeByField($meta, 'container_' . static::FIELD_MESSAGE_AVAILABLE);
     if (!$groupCode) {
         return $meta;
     }
     $containerPath = $this->arrayManager->findPath('container_' . static::FIELD_MESSAGE_AVAILABLE, $meta, null, 'children');
     $fieldPath = $this->arrayManager->findPath(static::FIELD_MESSAGE_AVAILABLE, $meta, null, 'children');
     $groupConfig = $this->arrayManager->get($containerPath, $meta);
     $fieldConfig = $this->arrayManager->get($fieldPath, $meta);
     $meta = $this->arrayManager->merge($containerPath, $meta, ['arguments' => ['data' => ['config' => ['formElement' => 'container', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/group', 'label' => $groupConfig['arguments']['data']['config']['label'], 'breakLine' => false, 'sortOrder' => $fieldConfig['arguments']['data']['config']['sortOrder'], 'dataScope' => '']]]]);
     $meta = $this->arrayManager->merge($containerPath, $meta, ['children' => [static::FIELD_MESSAGE_AVAILABLE => ['arguments' => ['data' => ['config' => ['dataScope' => static::FIELD_MESSAGE_AVAILABLE, 'imports' => ['disabled' => '${$.parentName}.use_config_' . static::FIELD_MESSAGE_AVAILABLE . ':checked'], 'additionalClasses' => 'admin__field-x-small', 'formElement' => Checkbox::NAME, 'componentType' => Field::NAME, 'prefer' => 'toggle', 'valueMap' => ['false' => '0', 'true' => '1']]]]], 'use_config_' . static::FIELD_MESSAGE_AVAILABLE => ['arguments' => ['data' => ['config' => ['dataType' => 'number', 'formElement' => Checkbox::NAME, 'componentType' => Field::NAME, 'description' => __('Use Config Settings'), 'dataScope' => 'use_config_' . static::FIELD_MESSAGE_AVAILABLE, 'valueMap' => ['false' => '0', 'true' => '1']]]]]]]);
     return $meta;
 }
Exemplo n.º 6
0
 /**
  * Adding URL rewrite checkbox to meta
  *
  * @param array $meta
  * @return array
  */
 protected function addUrlRewriteCheckbox(array $meta)
 {
     $urlPath = $this->arrayManager->findPath(ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY, $meta, null, 'children');
     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_Catalog/js/components/url-key-handle-changes', 'valueMap' => ['false' => '', 'true' => $urlKey], 'imports' => ['urlKey' => '${ $.provider }:data.product.' . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY, 'handleUseDefault' => '${ $.parentName }.url_key:isUseDefault', '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;
 }
 /**
  * Customize date range field if from and to fields belong to one group
  *
  * @param array $meta
  * @return array
  */
 protected function customizeDateRangeField(array $meta)
 {
     if ($this->getGroupCodeByField($meta, self::CODE_CUSTOM_DESIGN_FROM) !== $this->getGroupCodeByField($meta, self::CODE_CUSTOM_DESIGN_TO)) {
         return $meta;
     }
     $fromFieldPath = $this->arrayManager->findPath(self::CODE_CUSTOM_DESIGN_FROM, $meta, null, 'children');
     $toFieldPath = $this->arrayManager->findPath(self::CODE_CUSTOM_DESIGN_TO, $meta, null, 'children');
     $fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
     $toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
     $meta = $this->arrayManager->merge($fromFieldPath . self::META_CONFIG_PATH, $meta, ['label' => __('Schedule Update From'), 'additionalClasses' => 'admin__field-date']);
     $meta = $this->arrayManager->merge($toFieldPath . self::META_CONFIG_PATH, $meta, ['label' => __('To'), 'scopeLabel' => null, 'additionalClasses' => 'admin__field-date']);
     $meta = $this->arrayManager->merge($fromContainerPath . self::META_CONFIG_PATH, $meta, ['label' => __('Schedule Update From'), 'additionalClasses' => 'admin__control-grouped-date', 'breakLine' => false, 'component' => 'Magento_Ui/js/form/components/group']);
     $meta = $this->arrayManager->set($fromContainerPath . '/children/' . self::CODE_CUSTOM_DESIGN_TO, $meta, $this->arrayManager->get($toFieldPath, $meta));
     return $this->arrayManager->remove($toContainerPath, $meta);
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 /**
  * Customize msrp display actual price field
  *
  * @return $this
  */
 protected function customizeMsrpDisplayActualPrice()
 {
     $msrpDisplayPath = $this->arrayManager->findPath(static::FIELD_MSRP_DISPLAY_ACTUAL_PRICE, $this->meta, null, 'children');
     if ($msrpDisplayPath) {
         if (!$this->msrpConfig->isEnabled()) {
             $this->meta = $this->arrayManager->remove($this->arrayManager->slicePath($msrpDisplayPath, 0, -2), $this->meta);
         }
     }
     return $this;
 }
Exemplo n.º 10
0
 /**
  * Customize Advanced Pricing Panel
  *
  * @return $this
  */
 protected function customizeAdvancedPricing()
 {
     $this->meta['advanced-pricing']['arguments']['data']['config']['opened'] = true;
     $this->meta['advanced-pricing']['arguments']['data']['config']['collapsible'] = false;
     $this->meta['advanced-pricing']['arguments']['data']['config']['label'] = '';
     $this->meta['advanced_pricing_modal']['arguments']['data']['config'] = ['isTemplate' => false, 'componentType' => Modal::NAME, 'dataScope' => '', 'provider' => 'product_form.product_form_data_source', 'onCancel' => 'actionDone', 'options' => ['title' => __('Advanced Pricing'), 'buttons' => [['text' => __('Done'), 'class' => 'action-primary', 'actions' => [['targetName' => '${ $.name }', 'actionName' => 'actionDone']]]]]];
     $this->meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CONTAINER_PREFIX . ProductAttributeInterface::CODE_PRICE, $this->meta, null, 'children'), $this->meta, ['arguments' => ['data' => ['config' => ['component' => 'Magento_Ui/js/form/components/group']]]]);
     $this->meta['advanced_pricing_modal']['children']['advanced-pricing'] = $this->meta['advanced-pricing'];
     unset($this->meta['advanced-pricing']);
     return $this;
 }
Exemplo n.º 11
0
 /**
  * Customize Categories field
  *
  * @param array $meta
  * @return array
  */
 protected function customizeCategoriesField(array $meta)
 {
     $fieldCode = 'category_ids';
     $elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
     $containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
     if (!$elementPath) {
         return $meta;
     }
     $meta = $this->arrayManager->merge($containerPath, $meta, ['arguments' => ['data' => ['config' => ['label' => __('Categories'), 'dataScope' => '', 'breakLine' => false, 'formElement' => 'container', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/group', 'scopeLabel' => __('[GLOBAL]')]]], 'children' => [$fieldCode => ['arguments' => ['data' => ['config' => ['formElement' => 'select', 'componentType' => 'field', 'component' => 'Magento_Catalog/js/components/new-category', 'filterOptions' => true, 'chipsEnabled' => true, 'disableLabel' => true, 'levelsVisibility' => '1', 'elementTmpl' => 'ui/grid/filters/elements/ui-select', 'options' => $this->getCategoriesTree(), 'listens' => ['index=create_category:responseData' => 'setParsed', 'newOption' => 'toggleOptionSelected'], 'config' => ['dataScope' => $fieldCode, 'sortOrder' => 10]]]]], 'create_category_button' => ['arguments' => ['data' => ['config' => ['title' => __('New Category'), 'formElement' => 'container', 'additionalClasses' => 'admin__field-small', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/button', 'template' => 'ui/form/components/button/container', 'actions' => [['targetName' => 'product_form.product_form.create_category_modal', 'actionName' => 'toggleModal'], ['targetName' => 'product_form.product_form.create_category_modal.create_category', 'actionName' => 'render'], ['targetName' => 'product_form.product_form.create_category_modal.create_category', 'actionName' => 'resetForm']], 'additionalForGroup' => true, 'provider' => false, 'source' => 'product_details', 'displayArea' => 'insideGroup', 'sortOrder' => 20]]]]]]);
     return $meta;
 }
Exemplo n.º 12
0
 /**
  * @return void
  */
 private function prepareMeta()
 {
     $fieldCode = 'quantity_and_stock_status';
     $pathField = $this->arrayManager->findPath($fieldCode, $this->meta, null, 'children');
     if ($pathField) {
         $labelField = $this->arrayManager->get($this->arrayManager->slicePath($pathField, 0, -2) . '/arguments/data/config/label', $this->meta);
         $fieldsetPath = $this->arrayManager->slicePath($pathField, 0, -4);
         $this->meta = $this->arrayManager->merge($pathField . '/arguments/data/config', $this->meta, ['label' => __('Stock Status'), 'value' => '1', 'dataScope' => $fieldCode . '.is_in_stock', 'scopeLabel' => '[GLOBAL]']);
         $this->meta = $this->arrayManager->merge($this->arrayManager->slicePath($pathField, 0, -2) . '/arguments/data/config', $this->meta, ['label' => __('Stock Status'), 'scopeLabel' => '[GLOBAL]']);
         $container['arguments']['data']['config'] = ['formElement' => 'container', 'componentType' => 'container', 'component' => "Magento_Ui/js/form/components/group", 'label' => $labelField, 'breakLine' => false, 'dataScope' => $fieldCode, 'scopeLabel' => '[GLOBAL]', 'source' => 'product_details', 'sortOrder' => (int) $this->arrayManager->get($this->arrayManager->slicePath($pathField, 0, -2) . '/arguments/data/config/sortOrder', $this->meta) - 1];
         $qty['arguments']['data']['config'] = ['component' => 'Magento_CatalogInventory/js/components/qty-validator-changer', 'dataType' => 'number', 'formElement' => 'input', 'componentType' => 'field', 'visible' => '1', 'require' => '0', 'additionalClasses' => 'admin__field-small', 'dataScope' => 'qty', 'validation' => ['validate-number' => true, 'validate-digits' => true], 'imports' => ['handleChanges' => '${$.provider}:data.product.stock_data.is_qty_decimal'], 'sortOrder' => 10];
         $advancedInventoryButton['arguments']['data']['config'] = ['displayAsLink' => true, 'formElement' => 'container', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/button', 'template' => 'ui/form/components/button/container', 'actions' => [['targetName' => 'product_form.product_form.advanced_inventory_modal', 'actionName' => 'toggleModal']], 'title' => __('Advanced Inventory'), 'provider' => false, 'additionalForGroup' => true, 'source' => 'product_details', 'sortOrder' => 20];
         $container['children'] = ['qty' => $qty, 'advanced_inventory_button' => $advancedInventoryButton];
         $this->meta = $this->arrayManager->merge($fieldsetPath . '/children', $this->meta, ['quantity_and_stock_status_qty' => $container]);
     }
 }
Exemplo n.º 13
0
 /**
  * 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];
     $textListeners = [ProductAttributeInterface::CODE_SEO_FIELD_META_KEYWORD, ProductAttributeInterface::CODE_SEO_FIELD_META_DESCRIPTION];
     foreach ($listeners as $listener) {
         $listenerPath = $this->arrayManager->findPath($listener, $meta, null, 'children');
         $importsConfig = ['mask' => $this->locator->getStore()->getConfig('catalog/fields_masks/' . $listener), 'component' => 'Magento_Catalog/js/components/import-handler', 'imports' => ['handleNameChanges' => '${$.provider}:data.product.name', 'handleDescriptionChanges' => '${$.provider}:data.product.description', 'handleSkuChanges' => '${$.provider}:data.product.sku', 'handleColorChanges' => '${$.provider}:data.product.color', 'handleCountryChanges' => '${$.provider}:data.product.country_of_manufacture', 'handleGenderChanges' => '${$.provider}:data.product.gender', 'handleMaterialChanges' => '${$.provider}:data.product.material', 'handleShortDescriptionChanges' => '${$.provider}:data.product.short_description', 'handleSizeChanges' => '${$.provider}:data.product.size'], 'allowImport' => !$this->locator->getProduct()->getId()];
         if (!in_array($listener, $textListeners)) {
             $importsConfig['elementTmpl'] = 'ui/form/element/input';
         }
         $meta = $this->arrayManager->merge($listenerPath . static::META_CONFIG_PATH, $meta, $importsConfig);
     }
     $skuPath = $this->arrayManager->findPath(ProductAttributeInterface::CODE_SKU, $meta, null, 'children');
     $meta = $this->arrayManager->merge($skuPath . static::META_CONFIG_PATH, $meta, ['autoImportIfEmpty' => true]);
     $namePath = $this->arrayManager->findPath(ProductAttributeInterface::CODE_NAME, $meta, null, 'children');
     return $this->arrayManager->merge($namePath . static::META_CONFIG_PATH, $meta, ['valueUpdate' => 'keyup']);
 }
Exemplo n.º 14
0
 /**
  * Get config for container with common fields for any type
  *
  * @param int $sortOrder
  * @return array
  */
 protected function getCommonContainerConfig($sortOrder)
 {
     $commonContainer = ['arguments' => ['data' => ['config' => ['componentType' => Container::NAME, 'formElement' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/group', 'breakLine' => false, 'showLabel' => false, 'additionalClasses' => 'admin__field-group-columns admin__control-group-equal', 'sortOrder' => $sortOrder]]], 'children' => [static::FIELD_OPTION_ID => $this->getOptionIdFieldConfig(10), static::FIELD_TITLE_NAME => $this->getTitleFieldConfig(20, ['arguments' => ['data' => ['config' => ['label' => __('Option Title'), 'component' => 'Magento_Catalog/component/static-type-input', 'valueUpdate' => 'input', 'imports' => ['optionId' => '${ $.provider }:${ $.parentScope }.option_id']]]]]), static::FIELD_TYPE_NAME => $this->getTypeFieldConfig(30), static::FIELD_IS_REQUIRE_NAME => $this->getIsRequireFieldConfig(40)]];
     if ($this->locator->getProduct()->getStoreId()) {
         $useDefaultConfig = ['service' => ['template' => 'Magento_Catalog/form/element/helper/custom-option-service']];
         $titlePath = $this->arrayManager->findPath(static::FIELD_TITLE_NAME, $commonContainer, null) . static::META_CONFIG_PATH;
         $commonContainer = $this->arrayManager->merge($titlePath, $commonContainer, $useDefaultConfig);
     }
     return $commonContainer;
 }
Exemplo n.º 15
0
 /**
  * Modify Shipment Type configuration
  *
  * @param array $meta
  * @return array
  */
 private function modifyShipmentType(array $meta)
 {
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CODE_SHIPMENT_TYPE, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['dataScope' => 'data.product.shipment_type', 'validation' => ['required-entry' => false]]);
     return $meta;
 }
Exemplo n.º 16
0
 /**
  * @param array|mixed $indexes
  * @param array $data
  * @param string|array|null $startPath
  * @param string|array|null $internalPath
  * @param array $result
  * @dataProvider findPathDataProvider
  */
 public function testFindPath($indexes, array $data, $startPath, $internalPath, $result)
 {
     $this->assertSame($result, $this->arrayManager->findPath($indexes, $data, $startPath, $internalPath));
 }
Exemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function modifyMeta(array $meta)
 {
     $meta = $this->arrayManager->merge($this->arrayManager->findPath(static::CODE_SKU_TYPE, $meta, null, 'children') . static::META_CONFIG_PATH, $meta, ['valueMap' => ['false' => '1', 'true' => '0'], 'validation' => ['required-entry' => false]]);
     return $meta;
 }