コード例 #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;
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * @return void
  */
 public function testModifyMeta()
 {
     $this->locatorMock->expects($this->exactly(2))->method('getProduct')->willReturn($this->productMock);
     $this->productMock->expects($this->any())->method('getTypeId');
     $this->arrayManagerMock->expects($this->exactly(3))->method('set')->willReturn([]);
     $this->assertEquals([], $this->downloadablePanel->modifyMeta([]));
 }
コード例 #5
0
ファイル: Composite.php プロジェクト: Doability/magento2dev
 /**
  * {@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
ファイル: BundlePrice.php プロジェクト: Doability/magento2dev
 /**
  * {@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
 protected function setUp()
 {
     $this->productLocatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
     $this->productLocatorMock->expects(static::any())->method('getProduct')->willReturn($this->productMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->stockDataModifier = $this->objectManagerHelper->getObject(StockDataModifier::class, ['locator' => $this->productLocatorMock]);
 }
コード例 #8
0
 /**
  * {@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
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->locatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class)->disableOriginalConstructor()->getMock();
     $this->arrayManagerMock->expects($this->any())->method('get')->willReturnArgument(3);
 }
コード例 #11
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;
 }
コード例 #12
0
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->productMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false, false);
     $this->locatorMock = $this->getMock('Magento\\Catalog\\Model\\Locator\\LocatorInterface', [], []);
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->dataHelperMock = $this->getMock('Magento\\GoogleOptimizer\\Helper\\Data', [], [], '', false, false);
     $this->codeHelperMock = $this->getMock('Magento\\GoogleOptimizer\\Helper\\Code', [], [], '', false, false);
     $this->googleOptimizer = $this->objectManagerHelper->getObject(GoogleOptimizer::class, ['locator' => $this->locatorMock, 'dataHelper' => $this->dataHelperMock, 'codeHelper' => $this->codeHelperMock]);
 }
コード例 #13
0
 protected function setUp()
 {
     $this->productLocatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
     $this->productLocatorMock->expects(static::any())->method('getProduct')->willReturn($this->productMock);
     $this->urlBuilderMock->expects(static::any())->method('addSessionParam')->willReturnSelf();
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->configurablePanelModifier = $this->objectManagerHelper->getObject(ConfigurablePanelModifier::class, ['locator' => $this->productLocatorMock, 'urlBuilder' => $this->urlBuilderMock]);
 }
コード例 #14
0
 protected function setUp()
 {
     $this->productLocatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)->getMockForAbstractClass();
     $this->associatedProductsMock = $this->getMockBuilder(AssociatedProducts::class)->disableOriginalConstructor()->getMock();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->getMockForAbstractClass();
     $this->allowedProductTypesMock = $this->getMock(AllowedProductTypes::class, [], [], '', false);
     $this->productLocatorMock->expects(static::any())->method('getProduct')->willReturn($this->productMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
 }
コード例 #15
0
ファイル: EavTest.php プロジェクト: rafaelstz/magento2
 /**
  * @magentoDataFixture Magento/Catalog/_files/product_simple_with_admin_store.php
  */
 public function testModifyData()
 {
     /** @var \Magento\Catalog\Model\Product $product */
     $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
     $product->load(1);
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($product);
     $expectedData = (include __DIR__ . '/_files/eav_expected_data_output.php');
     $actualData = $this->eavModifier->modifyData([]);
     $this->prepareDataForComparison($actualData, $expectedData);
     $this->assertEquals($expectedData, $actualData);
 }
コード例 #16
0
ファイル: StockData.php プロジェクト: Doability/magento2dev
 /**
  * {@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;
 }
コード例 #17
0
 /**
  * {@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);
 }
コード例 #18
0
 /**
  * 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;
 }
コード例 #19
0
ファイル: System.php プロジェクト: Doability/magento2dev
 /**
  * {@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]]);
 }
コード例 #20
0
ファイル: Msrp.php プロジェクト: Doability/magento2dev
 /**
  * Customize msrp field
  *
  * @return $this
  */
 protected function customizeMsrp()
 {
     $msrpPath = $this->arrayManager->findPath(static::FIELD_MSRP, $this->meta, null, 'children');
     if ($msrpPath) {
         if ($this->msrpConfig->isEnabled()) {
             $this->meta = $this->arrayManager->merge($msrpPath . '/arguments/data/config', $this->meta, ['addbefore' => $this->locator->getStore()->getBaseCurrency()->getCurrencySymbol(), 'validation' => ['validate-zero-or-greater' => true]]);
         } else {
             $this->meta = $this->arrayManager->remove($this->arrayManager->slicePath($msrpPath, 0, -2), $this->meta);
         }
     }
     return $this;
 }
コード例 #21
0
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->meta = ['some_meta'];
     $this->modifiedMeta = ['modified_meta'];
     $this->modifierClass = 'SomeClass';
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class);
     $this->locatorMock = $this->getMock(\Magento\Catalog\Model\Locator\LocatorInterface::class);
     $this->productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class);
     $this->locatorMock->expects($this->once())->method('getProduct')->willReturn($this->productMock);
     $this->composite = $this->objectManagerHelper->getObject(\Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite::class, ['locator' => $this->locatorMock, 'objectManager' => $this->objectManagerMock, 'modifiers' => ['mod' => $this->modifierClass]]);
 }
コード例 #22
0
 /**
  * {@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;
 }
コード例 #23
0
ファイル: Composite.php プロジェクト: Doability/magento2dev
 /**
  * {@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;
 }
コード例 #24
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;
 }
コード例 #25
0
 /**
  * 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;
 }
コード例 #26
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->locatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
     $this->productMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['getStoreId', 'getResource', 'getData', 'getAttributes', 'getStore', 'getAttributeDefaultValue', 'getExistsStoreValueFlag'])->getMockForAbstractClass();
     $this->storeMock = $this->getMockBuilder(StoreInterface::class)->setMethods(['load', 'getId', 'getConfig'])->getMockForAbstractClass();
     $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class)->disableOriginalConstructor()->getMock();
     $this->arrayManagerMock->expects($this->any())->method('replace')->willReturnArgument(1);
     $this->arrayManagerMock->expects($this->any())->method('get')->willReturnArgument(2);
     $this->arrayManagerMock->expects($this->any())->method('set')->willReturnArgument(1);
     $this->arrayManagerMock->expects($this->any())->method('merge')->willReturnArgument(1);
     $this->arrayManagerMock->expects($this->any())->method('remove')->willReturnArgument(1);
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->locatorMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
 }
コード例 #27
0
 /**
  * {@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;
 }
コード例 #28
0
ファイル: Links.php プロジェクト: Doability/magento2dev
 /**
  * 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;
 }
コード例 #29
0
ファイル: Related.php プロジェクト: Doability/magento2dev
 /**
  * {@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;
 }
コード例 #30
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;
 }