本文整理汇总了PHP中Magento\Weee\Helper\Data::getWeeAttributesForBundle方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getWeeAttributesForBundle方法的具体用法?PHP Data::getWeeAttributesForBundle怎么用?PHP Data::getWeeAttributesForBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Weee\Helper\Data
的用法示例。
在下文中一共展示了Data::getWeeAttributesForBundle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateProductOptions
/**
* Change default JavaScript templates for options rendering
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function updateProductOptions(\Magento\Framework\Event\Observer $observer)
{
$response = $observer->getEvent()->getResponseObject();
$options = $response->getAdditionalOptions();
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->_registry->registry('current_product');
if (!$product) {
return $this;
}
if ($this->_weeeData->isEnabled() && !$this->_weeeData->geDisplayIncl($product->getStoreId()) && !$this->_weeeData->geDisplayExcl($product->getStoreId())) {
// only do processing on bundle product
if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
if (!array_key_exists('optionTemplate', $options)) {
$options['optionTemplate'] = '<%- data.label %>' . '<% if (data.finalPrice.value) { %>' . ' +<%- data.finalPrice.formatted %>' . '<% } %>';
}
foreach ($this->_weeeData->getWeeAttributesForBundle($product) as $weeAttribute) {
$options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice' . $weeAttribute->getCode() . ') { %%>' . ' (' . $weeAttribute->getName() . ':<%%= data.weeePrice' . $weeAttribute->getCode() . '.formatted %%>)' . '<%% } %%>');
}
if ($this->_weeeData->geDisplayExlDescIncl($product->getStoreId())) {
$options['optionTemplate'] .= sprintf(' <%% if (data.weeePrice) { %%>' . '<%%= data.weeePrice.formatted %%>' . '<%% } %%>');
}
}
}
$response->setAdditionalOptions($options);
return $this;
}
示例2: testGetWeeAttributesForBundle
public function testGetWeeAttributesForBundle()
{
$weeObject = new \Magento\Framework\Object(['code' => 'fpt', 'amount' => '15.0000']);
$testArray = ['fpt' => $weeObject];
$this->weeeTax->expects($this->any())->method('getProductWeeeAttributes')->will($this->returnValue([$weeObject]));
$productSimple = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Type\\Simple', [], [], '', false);
$productInstance = $this->getMock('\\Magento\\Bundle\\Model\\Product\\Type', [], [], '', false);
$productInstance->expects($this->any())->method('getSelectionsCollection')->will($this->returnValue([$productSimple]));
$store = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
$product = $this->getMock('\\Magento\\Bundle\\Model\\Product', ['getTypeInstance', 'getStoreId', 'getStore', 'getTypeId'], [], '', false);
$product->expects($this->any())->method('getTypeInstance')->will($this->returnValue($productInstance));
$product->expects($this->any())->method('getStoreId')->will($this->returnValue(1));
$product->expects($this->any())->method('getStore')->will($this->returnValue($store));
$product->expects($this->any())->method('getTypeId')->will($this->returnValue('bundle'));
$registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
$registry->expects($this->any())->method('registry')->with('current_product')->will($this->returnValue($product));
$this->assertEquals($testArray, $this->_helperData->getWeeAttributesForBundle($product));
}