magento开发过程中代码小结:
1
得到当前产品:$pr = Mage::registry('current_product');
2
得到当前产品的价格:$dds = Mage::helper('core')->currency($pr->getPrice());
3
得到title为color的custom options 的css中的id属性
<?php $_options = Mage::helper('core')->decorateArray($this->getOptions()) ?>
foreach($_options as $_option){
if($_option['title']=="color"){
//echo "<div style='display:block;'>".$this->getOptionHtml($_option)."</div>";
$colorid = "select_".$_option['option_id'];
echo $colorid;
}
}
4
得到select中的每一个子项
$op = $_option->getValues();
<?php foreach($_options as $_option){ ?>
<?php
if($_option['title']=="color"){
$op = $_option->getValues();
foreach($op as $ops){
echo "<span >".$ops->getTitle()."##".$ops->getOptionTypeId()."</span>";
$d1s = $ops->getTitle();
}
<?php } ?>
5
输出这个options项
<?php foreach($_options as $_option):{?>
<?php $this->getOptionHtml($_option); ?>
<?php } ?>
OK!