0

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:

<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_productCollection->addAttributeToSelect('news_from_date')
        ->addAttributeToSelect('news_to_date');
    $_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');?>
<?php 
    $products_count = Mage::getModel('catalog/category')->load($_category_detail->getId())->getProductCount();
?>
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, privacy policy and cookie policy

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