如何在magento 1.9.3中获取自定义选项值?

时间:2016-11-23 09:58:25

标签: php magento

如何在magento 1.9.3中获取自定义选项值? 我的代码在下面,但没有工作请帮助我

 $helper   = Mage::helper('catalog/product_configuration');
 print_r($helper->getCustomOptions());

1 个答案:

答案 0 :(得分:0)

使用以下代码,我认为帮助你

$helper   = Mage::helper('catalog/product_configuration');
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); 
$wt=0;
foreach($items as $item){  
    $categories_array = $item->getProduct()->getCategoryIds(); 

    $_options = $helper->getCustomOptions($item);
    foreach ($_options as $_option) {
        $value = $this->htmlEscape($_option['value']);
        $weigth=preg_replace("/[^0-9,.]/","", $value);
        echo $wt+= $weigth;
    }
}