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.

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 />" ;
}

This is what I did. Hope it helps come body.

<?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 />'; 
} ?>

I put the above code just below

<?php echo $this->getColumnHtml($_item, 'name') ?>

on line number 35 on the page app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml