如何在magento的结帐和订单页面上获取自定义类别属性值

时间:2014-09-13 09:03:06

标签: php magento

我为我的类别创建了自定义属性。我想在我的结帐页面和订单页面上获取该属性,但是在购物车页面之后没有获得该值。我还试过使用会话变量但是如果购物车中添加了多个产品,它会覆盖以前的类别属性值。

这是我用 default.phtml

编写的会话变量代码
$id = $_item->getProduct()->getId();
$product = Mage::getModel('Catalog/product')->load($id);
$categorysku = $product->getCategory();
$product->getCategoryIds();
echo $categorysku->getData('category-sku');// required category attribute value

提前感谢任何建议或解决方案。

1 个答案:

答案 0 :(得分:1)

在订单行中保留自定义类别属性值不是一个更好的主意吗?

在这种情况下,您将创建一个在

上触发的观察者
 sales_quote_item_set_product

它看起来像:

 class Namespace_Modulename_Model_Observer extends Varien_Object
 {
     public function salesQuoteItemSetCustomCategoryAttribute($observer)
     {
        // Your save custom category attribute to order line logic...
        return $this;
     }
  }