예제 #1
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;
 }
 /**
  * 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);
 }
예제 #3
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;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function modifyMeta(array $meta)
 {
     $path = $this->arrayManager->findPath(static::CODE_BUNDLE_DATA, $meta, null, 'children');
     $meta = $this->arrayManager->merge($path, $meta, ['arguments' => ['data' => ['config' => ['dataScope' => '', 'opened' => true, 'sortOrder' => $this->getNextGroupSortOrder($meta, static::GROUP_CONTENT, static::SORT_ORDER)]]], 'children' => ['modal' => ['arguments' => ['data' => ['config' => ['isTemplate' => false, 'componentType' => Modal::NAME, 'dataScope' => '', 'provider' => 'product_form.product_form_data_source', 'options' => ['title' => __('Add Products to Option'), 'buttons' => [['text' => __('Cancel'), 'actions' => ['closeModal']], ['text' => __('Add Selected Products'), 'class' => 'action-primary', 'actions' => [['targetName' => 'index = bundle_product_listing', 'actionName' => 'save'], 'closeModal']]]]]]], 'children' => ['bundle_product_listing' => ['arguments' => ['data' => ['config' => ['autoRender' => false, 'componentType' => 'insertListing', 'dataScope' => 'bundle_product_listing', 'externalProvider' => 'bundle_product_listing.bundle_product_listing_data_source', 'selectionsProvider' => 'bundle_product_listing.bundle_product_listing.product_columns.ids', 'ns' => 'bundle_product_listing', 'render_url' => $this->urlBuilder->getUrl('mui/index/render'), 'realTimeLink' => false, 'dataLinks' => ['imports' => false, 'exports' => true], 'behaviourType' => 'simple', 'externalFilterMode' => true]]]]]], self::CODE_AFFECT_BUNDLE_PRODUCT_SELECTIONS => ['arguments' => ['data' => ['config' => ['componentType' => Form\Field::NAME, 'dataType' => Form\Element\DataType\Text::NAME, 'formElement' => Form\Element\Input::NAME, 'dataScope' => 'data.affect_bundle_product_selections', 'visible' => false, 'value' => '1']]]], self::CODE_BUNDLE_HEADER => $this->getBundleHeader(), self::CODE_BUNDLE_OPTIONS => $this->getBundleOptions()]]);
     //TODO: Remove this workaround after MAGETWO-49902 is fixed
     $bundleItemsGroup = $this->arrayManager->get($path, $meta);
     $meta = $this->arrayManager->remove($path, $meta);
     $meta = $this->arrayManager->set($path, $meta, $bundleItemsGroup);
     $meta = $this->modifyShipmentType($meta);
     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);
 }
예제 #6
0
 /**
  * @return array
  */
 protected function getMaxDownloadsColumn()
 {
     $maxDownloadsContainer['arguments']['data']['config'] = ['componentType' => Container::NAME, 'formElement' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/group', 'label' => __('Max. Downloads'), 'dataScope' => ''];
     $numberOfDownloadsField['arguments']['data']['config'] = ['formElement' => Form\Element\Input::NAME, 'componentType' => Form\Field::NAME, 'dataType' => Form\Element\DataType\Number::NAME, 'dataScope' => 'number_of_downloads', 'value' => 0, 'validation' => ['validate-zero-or-greater' => true, 'validate-number' => true]];
     $isUnlimitedField['arguments']['data']['config'] = ['formElement' => Form\Element\Checkbox::NAME, 'componentType' => Form\Field::NAME, 'dataType' => Form\Element\DataType\Number::NAME, 'dataScope' => 'is_unlimited', 'description' => __('Unlimited'), 'valueMap' => ['false' => '0', 'true' => '1'], 'exports' => ['checked' => '${$.parentName}.number_of_downloads:disabled']];
     return $this->arrayManager->set('children', $maxDownloadsContainer, ['number_of_downloads' => $numberOfDownloadsField, 'is_unlimited' => $isUnlimitedField]);
 }
 /**
  * @return array
  */
 protected function getSampleColumn()
 {
     $sampleContainer['arguments']['data']['config'] = ['componentType' => Container::NAME, 'formElement' => Container::NAME, 'component' => 'Magento_Ui/js/form/components/group', 'label' => __('File'), 'dataScope' => ''];
     $sampleType['arguments']['data']['config'] = ['formElement' => Form\Element\Select::NAME, 'componentType' => Form\Field::NAME, 'component' => 'Magento_Downloadable/js/components/upload-type-handler', 'dataType' => Form\Element\DataType\Text::NAME, 'dataScope' => 'type', 'options' => $this->typeUpload->toOptionArray(), 'typeFile' => 'sample_file', 'typeUrl' => 'sample_url'];
     $sampleUrl['arguments']['data']['config'] = ['formElement' => Form\Element\Input::NAME, 'componentType' => Form\Field::NAME, 'dataType' => Form\Element\DataType\Text::NAME, 'dataScope' => 'sample_url', 'placeholder' => 'URL', 'validation' => ['required-entry' => true, 'validate-url' => true]];
     $sampleUploader['arguments']['data']['config'] = ['formElement' => 'fileUploader', 'componentType' => 'fileUploader', 'component' => 'Magento_Downloadable/js/components/file-uploader', 'elementTmpl' => 'Magento_Downloadable/components/file-uploader', 'fileInputName' => 'samples', 'uploaderConfig' => ['url' => $this->urlBuilder->addSessionParam()->getUrl('adminhtml/downloadable_file/upload', ['type' => 'samples', '_secure' => true])], 'dataScope' => 'file', 'validation' => ['required-entry' => true]];
     return $this->arrayManager->set('children', $sampleContainer, ['sample_type' => $sampleType, 'sample_url' => $sampleUrl, 'sample_file' => $sampleUploader]);
 }
예제 #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;
 }
예제 #9
0
 /**
  * Customize options
  *
  * @param array $meta
  * @return array
  */
 private function customizeOptions($meta)
 {
     $sortOrder = 1;
     foreach ($this->storeRepository->getList() as $store) {
         $storeId = $store->getId();
         $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]);
         $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]);
         ++$sortOrder;
     }
     $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']);
     $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']);
     return $meta;
 }
예제 #10
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;
 }
예제 #11
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;
 }
예제 #12
0
 /**
  * Create slide-out panel for new category creation
  *
  * @param array $meta
  * @return array
  */
 protected function createNewCategoryModal(array $meta)
 {
     return $this->arrayManager->set('create_category_modal', $meta, ['arguments' => ['data' => ['config' => ['isTemplate' => false, 'componentType' => 'modal', 'options' => ['title' => __('New Category')], 'imports' => ['state' => '!index=create_category:responseStatus']]]], 'children' => ['create_category' => ['arguments' => ['data' => ['config' => ['label' => '', 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/insert-form', 'dataScope' => '', 'update_url' => $this->urlBuilder->getUrl('mui/index/render'), 'render_url' => $this->urlBuilder->getUrl('mui/index/render_handle', ['handle' => 'catalog_category_create', 'store' => $this->locator->getStore()->getId(), 'buttons' => 1]), 'autoRender' => false, 'ns' => 'new_category_form', 'externalProvider' => 'new_category_form.new_category_form_data_source', 'toolbarContainer' => '${ $.parentName }', 'formSubmitType' => 'ajax']]]]]]);
 }
예제 #13
0
파일: Eav.php 프로젝트: rafaelstz/magento2
 /**
  * Setup attribute container meta
  *
  * @param ProductAttributeInterface $attribute
  * @return array
  * @api
  */
 public function setupAttributeContainerMeta(ProductAttributeInterface $attribute)
 {
     $containerMeta = $this->arrayManager->set('arguments/data/config', [], ['formElement' => 'container', 'componentType' => 'container', 'breakLine' => false, 'label' => $attribute->getDefaultFrontendLabel(), 'required' => $attribute->getIsRequired()]);
     if ($attribute->getIsWysiwygEnabled()) {
         $containerMeta = $this->arrayManager->merge('arguments/data/config', $containerMeta, ['component' => 'Magento_Ui/js/form/components/group']);
     }
     return $containerMeta;
 }
 /**
  * @param string $path
  * @param array $data
  * @param mixed $value
  * @param array $result
  * @dataProvider setDataProvider
  */
 public function testReplace($path, $data, $value, $result)
 {
     $this->assertSame($result, $this->arrayManager->set($path, $data, $value));
 }