I have a problem while doing search in magento store...

Getting following error:

Fatal error: Call to a member function getId() on a non-object in
The line that is giving error is the last line in the below code:

Code I used is:

    $_helper = $this->helper('catalog/output');
    $store = Mage::app()->getStore();
    $code  = $store->getCode();
<?php $_helper = $this->helper('catalog/output');?>
<?php $_category_detail=Mage::registry('current_category');?>
    $products_count = Mage::getModel('catalog/category')->load($_category_detail->getId())->getProductCount();

1 Answer 1


The reason you are getting this error that you are trying to get current category object while searching an item in the list.phtml page. This object is not available in this context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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