Currently my product belong to many Categories, I want to get Category Name, from which product was ordered.

  • where you want the category name on sales->order grid of admin or somewhere else please specify. May 6, 2016 at 13:08
  • Yes, I have created my custom grid from order items, I want it there May 6, 2016 at 13:10
  • have you ever made use of renderer ? May 6, 2016 at 13:27
  • Did you find any best way>
    – Gem
    Aug 23, 2018 at 11:08

2 Answers 2


Abdul Ghaffar,magento does not save category details at sales model.So it not possible to get Category Name, from which product was ordered.

Magento save order only product id,sku at sales module.

If you want to then you need do customization,first you need to add a field to at sales_quote_item & sales_flat_order_item.

During cart,you need to add category id to sales_quote_item table.

During order place, convert that field value to sales_flat_order_table


try below code:

$product = Mage::getModel('catalog/product')->load($_item['product_id']);
$cats = $product->getCategoryIds();

foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->load($category_id);
     if (in_array($category_id, $elements)) {
          echo $_cat->getName();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.