/** * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { if ($this->getRequest()->getParam('website') != '') { $priceScope = $this->_scopeConfig->getValue(\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if ($priceScope == \Magento\Store\Model\Store::PRICE_SCOPE_GLOBAL) { return ''; } } return parent::render($element); }
public function testRenderInheritCheckbox() { $this->_elementMock->expects($this->any())->method('getInherit')->will($this->returnValue(true)); $this->_elementMock->expects($this->any())->method('getCanUseWebsiteValue')->will($this->returnValue(true)); $this->_elementMock->expects($this->any())->method('getCanUseDefaultValue')->will($this->returnValue(true)); $this->_elementMock->expects($this->once())->method('setDisabled')->with(true); $expected = '<td class="use-default">'; $expected .= '<input id="' . $this->_testData['htmlId'] . '_inherit" name="' . $this->_testData['name'] . '[inherit]" type="checkbox" value="1"' . ' class="checkbox config-inherit" checked="checked"' . ' onclick="toggleValueElements(this, Element.previous(this.parentNode))" /> '; $expected .= '<label for="' . $this->_testData['htmlId'] . '_inherit" class="inherit">Use Website</label>'; $actual = $this->_object->render($this->_elementMock); $this->assertContains($expected, $actual); }
/** * Render button * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { // Remove scope label $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); return parent::render($element); }
/** * Render country field considering request parameter * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $country = $this->getRequest()->getParam(StructurePlugin::REQUEST_PARAM_COUNTRY); if ($country) { $element->setValue($country); } if ($element->getCanUseDefaultValue()) { $this->_defaultCountry = $this->_scopeConfig->getValue(self::FIELD_CONFIG_PATH); if (!$this->_defaultCountry) { $this->_defaultCountry = $this->_coreHelper->getDefaultCountry(); } if ($country) { $shouldInherit = $country == $this->_defaultCountry && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT_COUNTRY); $element->setInherit($shouldInherit); } if ($element->getInherit()) { $this->_defaultCountry = null; } } return parent::render($element); }