duanpang1987 2015-12-01 09:30
浏览 55

Magento - 在“销售订单”视图中显示产品类别信息

Before starting, I would like to mention that I have seen this same name thread here. But this thread didn't answer anything and that is the reason I posted the same thing again.

I would just need to display the categories of the products/SKU(s) ordered. It can be displayed below the SKU or in a separate column. Please guide me as to how to achieve that.

  • 写回答

2条回答 默认 最新

  • down123321123 2015-12-01 09:58
    关注

    Your question is a little lacking in detail, however I believe you want to take the items that made up a previous order, and show the category of each product?

    This is the code that would do all of that in a loop - considering you've not said what template you want it to be in, if it's in the account area, or in an email or the order confirmation screen etc, you'll have to figure out the bits you need and the bits you don't:

    $order = Mage::getModel('sales/order')->loadByIncrementId(500001); //Load a specific order
    $items = $order->getAllVisibleItems(); // Get the items that make up this order
    foreach ($items as $item){
        $categoryIds = $item->getProduct()->getCategoryIds();
        $bottomCategory = Mage::getModel('catalog/category')->load(end($categoryIds)); //We only want one category, so get the very last one
        echo $item->getSku() . " has a category of " . $bottomCategory->getName() . "<br />" ;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播