【发布时间】:2014-02-28 20:33:07
【问题描述】:
我似乎无法在下面的 magento 代码中显示自定义选项字段 - 你们中的任何一个好人可以帮助我吗?
public function getProductName($product)
{
$value = '<b>'.$product->getname().'</b>';
if ($product->getproduct_type() == 'configurable')
{
//add sub products
$collection = mage::getModel('sales/order_item')
->getCollection()
->addFieldToFilter('parent_item_id', $product->getitem_id());
foreach ($collection as $subProduct)
{
$value .= '<br><i>'.$subProduct->getname().'</i>';
//add product configurable attributes values
$attributesDescription = mage::helper('ProductReturn/Configurable')->getDescription($subProduct->getproduct_id(), $product->getrp_product_id());
if ($attributesDescription != '')
$value .= '<br>'.$attributesDescription;
}
}
return $value;
}
【问题讨论】:
-
您好,如果 $product 是您的 productId,请尝试以下代码: $_product = $product;回声 $_product->getCustomOptionName(); getCustomOptionName 例如 forauction_type -> getAuction_type();
-
谢谢 Jaydeep - 我认为自定义选项会在 magento 中正常列出?由于提到了 2 个 $product 属性,我将把这段代码放在哪一行。
-
你是在说你的代码还是我的?
-
原代码中有2个$product属性