Exemplo n.º 1
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;
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
    public function testSlicePathCustomDelimiter()
    {
        $path = 'my~custom~path';

        $this->assertSame('custom', $this->arrayManager->slicePath($path, 1, 1, '~'));
        $this->assertSame('', $this->arrayManager->slicePath($path, 1, 1));
    }
Exemplo n.º 5
0
 /**
  * Customize msrp display actual price field
  *
  * @return $this
  */
 protected function customizeMsrpDisplayActualPrice()
 {
     $msrpDisplayPath = $this->getElementArrayPath($this->meta, self::FIELD_MSRP_DISPLAY_ACTUAL_PRICE);
     if ($msrpDisplayPath) {
         if (!$this->msrpConfig->isEnabled()) {
             $this->meta = $this->arrayManager->remove($this->arrayManager->slicePath($msrpDisplayPath, 0, -2), $this->meta);
         }
     }
     return $this;
 }
Exemplo n.º 6
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.º 7
0
 /**
  * Special price data move to inline group
  *
  * @return $this
  */
 protected function specialPriceDataToInline()
 {
     $pathFrom = $this->arrayManager->findPath('special_from_date', $this->meta, null, 'children');
     $pathTo = $this->arrayManager->findPath('special_to_date', $this->meta, null, 'children');
     if ($pathFrom && $pathTo) {
         $this->meta = $this->arrayManager->merge($this->arrayManager->slicePath($pathFrom, 0, -2) . '/arguments/data/config', $this->meta, ['label' => __('Special Price From'), 'additionalClasses' => 'admin__control-grouped-date', 'breakLine' => false, 'component' => 'Magento_Ui/js/form/components/group', 'scopeLabel' => $this->arrayManager->get($pathFrom . '/arguments/data/config/scopeLabel', $this->meta)]);
         $this->meta = $this->arrayManager->merge($pathFrom . '/arguments/data/config', $this->meta, ['label' => __('Special Price From'), 'scopeLabel' => null, 'additionalClasses' => 'admin__field-date']);
         $this->meta = $this->arrayManager->merge($pathTo . '/arguments/data/config', $this->meta, ['label' => __('To'), 'scopeLabel' => null, 'additionalClasses' => 'admin__field-date']);
         // Move special_to_date to special_from_date container
         $this->meta = $this->arrayManager->set($this->arrayManager->slicePath($pathFrom, 0, -1) . '/special_to_date', $this->meta, $this->arrayManager->get($pathTo, $this->meta));
         $this->meta = $this->arrayManager->remove($this->arrayManager->slicePath($pathTo, 0, -2), $this->meta);
     }
     return $this;
 }
 /**
  * @return void
  */
 private function prepareMeta()
 {
     $fieldCode = 'quantity_and_stock_status';
     $pathField = $this->getElementArrayPath($this->meta, $fieldCode);
     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.º 9
0
 /**
  * Customize "Set Product as New" date fields
  *
  * @param array $meta
  * @return array
  */
 protected function customizeNewDateRangeField(array $meta)
 {
     $fromField = 'news_from_date';
     $toField = 'news_to_date';
     $fromFieldPath = $this->arrayManager->findPath($fromField, $meta, null, 'children');
     $toFieldPath = $this->arrayManager->findPath($toField, $meta, null, 'children');
     if ($fromFieldPath && $toFieldPath) {
         $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' => __('Set Product as New 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' => __('Set Product as New From'), 'additionalClasses' => 'admin__control-grouped-date', 'breakLine' => false, 'component' => 'Magento_Ui/js/form/components/group']);
         $meta = $this->arrayManager->set($fromContainerPath . '/children/' . $toField, $meta, $this->arrayManager->get($toFieldPath, $meta));
         $meta = $this->arrayManager->remove($toContainerPath, $meta);
     }
     return $meta;
 }