首页 文章

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

提问于
浏览
1

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

这是我在 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 回答

  • 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;
         }
      }
    

相关问题