Exemplo n.º 1
0
 /**
  * @param \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes $subject
  * @param \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes $result
  * @return \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes
  */
 public function afterSetForm(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes $subject, \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes $result)
 {
     $form = $subject->getForm();
     $field = $form->getElement('url_key');
     if ($field) {
         $field->setRenderer($subject->getLayout()->createBlock('Magento\\CatalogUrlRewrite\\Block\\UrlKeyRenderer'));
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Prepare attributes form of bundle product
  *
  * @return void
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     parent::_prepareForm();
     $specialPrice = $this->getForm()->getElement('special_price');
     if ($specialPrice) {
         $specialPrice->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Special')->setDisableChild(false));
         $specialPrice->addClass(implode(' ', ['validate-greater-than-zero', 'validate-number-range', 'number-range-0.00-100.00']));
     }
     $sku = $this->getForm()->getElement('sku');
     if ($sku) {
         $sku->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend')->setDisableChild(false));
     }
     $price = $this->getForm()->getElement('price');
     if ($price) {
         $price->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend', 'adminhtml.catalog.product.bundle.edit.tab.attributes.price')->setDisableChild(true));
     }
     $tax = $this->getForm()->getElement('tax_class_id');
     if ($tax) {
         $tax->setAfterElementHtml('<script>' . "\n                require(['prototype'], function(){\n                function changeTaxClassId() {\n                    if (\$('price_type').value == '" . \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC . "') {\n                        \$('tax_class_id').disabled = true;\n                        \$('tax_class_id').value = '0';\n                        \$('tax_class_id').removeClassName('required-entry');\n                        if (\$('advice-required-entry-tax_class_id')) {\n                            \$('advice-required-entry-tax_class_id').remove();\n                        }\n                    } else {\n                        \$('tax_class_id').disabled = false;\n                        " . ($tax->getRequired() ? "\$('tax_class_id').addClassName('required-entry');" : '') . "\n                    }\n                }\n\n                if (\$('price_type')) {\n                    \$('price_type').observe('change', changeTaxClassId);\n                    changeTaxClassId();\n                }\n                });\n                " . '</script>');
     }
     $weight = $this->getForm()->getElement('weight');
     if ($weight) {
         $weight->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend')->setDisableChild(true));
     }
     $tier_price = $this->getForm()->getElement('tier_price');
     if ($tier_price) {
         $tier_price->setRenderer($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Price\\Tier')->setPriceColumnHeader(__('Percent Discount'))->setPriceValidation('validate-greater-than-zero validate-number-range number-range-0.00-100.00'));
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function setForm(\Magento\Framework\Data\Form $form)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setForm');
     if (!$pluginInfo) {
         return parent::setForm($form);
     } else {
         return $this->___callPlugins('setForm', func_get_args(), $pluginInfo);
     }
 }
Exemplo n.º 4
0
 /**
  * Prepare attributes form of bundle product
  *
  * @return void
  */
 protected function _prepareForm()
 {
     parent::_prepareForm();
     $specialPrice = $this->getForm()->getElement('special_price');
     if ($specialPrice) {
         $specialPrice->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Special')->setDisableChild(false));
         $specialPrice->addClass(implode(' ', ['validate-greater-than-zero', 'validate-number-range', 'number-range-0.00-100.00']));
     }
     $sku = $this->getForm()->getElement('sku');
     if ($sku) {
         $sku->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend')->setDisableChild(false));
     }
     $price = $this->getForm()->getElement('price');
     if ($price) {
         $price->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend', 'adminhtml.catalog.product.bundle.edit.tab.attributes.price')->setDisableChild(true));
     }
     $tax = $this->getForm()->getElement('tax_class_id');
     if ($tax) {
         $tax->setAfterElementHtml('<script type="text/javascript">' . "\n                //<![CDATA[\n                function changeTaxClassId() {\n                    if (\$('price_type').value == '" . \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC . "') {\n                        \$('tax_class_id').disabled = true;\n                        \$('tax_class_id').value = '0';\n                        \$('tax_class_id').removeClassName('required-entry');\n                        if (\$('advice-required-entry-tax_class_id')) {\n                            \$('advice-required-entry-tax_class_id').remove();\n                        }\n                    } else {\n                        \$('tax_class_id').disabled = false;\n                        " . ($tax->getRequired() ? "\$('tax_class_id').addClassName('required-entry');" : '') . "\n                    }\n                }\n\n                document.observe('dom:loaded', function() {\n                    if (\$('price_type')) {\n                        \$('price_type').observe('change', changeTaxClassId);\n                        changeTaxClassId();\n                    }\n                });\n                //]]>\n                " . '</script>');
     }
     $weight = $this->getForm()->getElement('weight');
     if ($weight) {
         $weight->setRenderer($this->getLayout()->createBlock('Magento\\Bundle\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Tab\\Attributes\\Extend')->setDisableChild(true));
     }
     $tier_price = $this->getForm()->getElement('tier_price');
     if ($tier_price) {
         $tier_price->setRenderer($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Price\\Tier')->setPriceColumnHeader(__('Percent Discount'))->setPriceValidation('validate-greater-than-zero validate-number-range number-range-0.00-100.00'));
     }
     $groupPrice = $this->getForm()->getElement('group_price');
     if ($groupPrice) {
         $groupPrice->setRenderer($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Price\\Group')->setPriceColumnHeader(__('Percent Discount'))->setPriceValidation('validate-greater-than-zero validate-number-range number-range-0.00-100.00'));
     }
     $mapEnabled = $this->getForm()->getElement('msrp_enabled');
     if ($mapEnabled && $this->getCanEditPrice() !== false) {
         $mapEnabled->setAfterElementHtml('<script type="text/javascript">' . "\n                function changePriceTypeMap() {\n                    if (\$('price_type').value == " . \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC . ") {\n                        \$('msrp_enabled').setValue(" . \Magento\Catalog\Model\Product\Attribute\Source\Msrp\Type\Enabled::MSRP_ENABLE_NO . ");\n                        \$('msrp_enabled').disable();\n                        \$('msrp_display_actual_price_type').setValue(" . \Magento\Catalog\Model\Product\Attribute\Source\Msrp\Type\Price::TYPE_USE_CONFIG . ");\n                        \$('msrp_display_actual_price_type').disable();\n                        \$('msrp').setValue('');\n                        \$('msrp').disable();\n                    } else {\n                        \$('msrp_enabled').enable();\n                        \$('msrp_display_actual_price_type').enable();\n                        \$('msrp').enable();\n                    }\n                }\n                document.observe('dom:loaded', function() {\n                    \$('price_type').observe('change', changePriceTypeMap);\n                    changePriceTypeMap();\n                });\n                " . '</script>');
     }
 }
Exemplo n.º 5
0
 /**
  * @param \Magento\Backend\Block\Template\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Data\FormFactory $formFactory
  * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
  * @param \Magento\Catalog\Helper\Data $catalogData
  * @param ProductFactory $productFactory
  * @param array $data
  */
 public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, \Magento\Catalog\Helper\Data $catalogData, ProductFactory $productFactory, array $data = array())
 {
     $this->_productFactory = $productFactory;
     parent::__construct($context, $registry, $formFactory, $wysiwygConfig, $catalogData, $data);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet');
     if (!$pluginInfo) {
         return parent::offsetGet($offset);
     } else {
         return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo);
     }
 }