1

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. – Ashish Madankar M2 Professiona May 6 '16 at 13:08
  • Yes, I have created my custom grid from order items, I want it there – Abdul Ghaffar May 6 '16 at 13:10
  • have you ever made use of renderer ? – Ashish Madankar M2 Professiona May 6 '16 at 13:27
  • Did you find any best way> – Gem Aug 23 '18 at 11:08
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

|improve this answer|||||
0

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();
     }
}
|improve this answer|||||

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.