在开始之前,我想提一下,我在这里看到了这个same name thread。但是这个帖子没有回答任何问题,这就是我再次发布同样内容的原因。
我只需要显示所订购产品/ SKU的类别。它可以显示在SKU下方或单独的列中。 请指导我如何实现这一目标。
答案 0 :(得分:0)
您的问题有点缺乏详细信息,但我相信您想要获取以前订单中的项目,并显示每种产品的类别?
这是在循环中完成所有操作的代码 - 考虑到你没有说出你希望它在哪个模板,如果它在帐户区域,或在电子邮件或订单确认屏幕等,你必须弄清楚你需要的位和你不需要的位:
$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 />" ;
}
答案 1 :(得分:0)
这就是我所做的。希望它有助于身体。
<?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('name', $_item->getData('name'));
$categoryIds = $_pullProduct->getCategoryIds();
foreach ($categoryIds as $cid) {
$category = Mage::getModel('catalog/category')->load($cid);
echo $category->getName() . '<br />';
} ?>
我把上面的代码放在
下面<?php echo $this->getColumnHtml($_item, 'name') ?>
在页面上的第35行 应用程序/设计/ adminhtml /默认/默认/模板/销售/订单/视图/项目/渲染器/ default.phtml