0

I want to get current category id while placing order.
I have tried code as below,

$layer = Mage::getSingleton('catalog/layer');  
$Category = $layer->getCurrentCategory();  
$currentCatId= $Category ->getId();

It is giving empty value.

  • This code works fine - $_product = Mage::getModel('catalog/product')->load($_item->getId()); $ids = $_product->getCategoryIds(); $categoryId = (isset($ids[0]) ? $ids[0] : null); – jassi Jul 13 '16 at 5:06
0

Use this code:

 $_product = Mage::getModel('catalog/product')->load($_item->getId()); 
 $categoryIds = $_product->getCategoryIds();
if(count($categoryIds) ){
  // YOUR CODE
}
| 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.