获得magento simple product的custom option信息

一段简单实用的代码获得magento中普通商品的自定义选项的值与信息。代码如下:

$product = Mage::getModel(‘catalog/product’)->load(174);
$options = $product->getOptions();//magento1.5版本
$options = Mage::helper(‘core’)->decorateArray($_prodcut->getOptions());//其他版本
$i = 1;
echo "<pre>";
foreach ($product->getOptions() as $o) {
echo "<strong>Custom Option:" . $i . "</strong><br/>";
echo "Custom Option TYPE: " . $o->getType() . "<br/>";
echo "Custom Option TITLE: " . $o->getTitle() . "<br/>";
echo "Custom Option ID: ". $o->getId() ."<br/>";
// Getting Values if it has option values, case of select,dropdown,radio,multiselect
$values = $o->getValues();
foreach ($values as $v) {
print_r($v->getData());
}
$i++;
}

你可能感兴趣的:(获得magento simple product的custom option信息)