0

I have override magento layer.php file and need to change some method. just like below.

public function getProductCollection()
    {
        if($this->getCurrentCategory()->getId()==290){
        $startprice=0;
            $endprice=499;
             $collection = Mage::getModel('catalog/product')->getCollection()
                        ->addAttributeToSelect('*')
                        ->addAttributeToFilter('price', array('gteq' => $startprice))
                        ->addAttributeToFilter('price', array('lteq' => $endprice))
                        ->getData();



        }else{
            if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
            $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
        } else {
            $collection = $this->getCurrentCategory()->getProductCollection();
            $this->prepareProductCollection($collection);
            $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
        }



        }

        return $collection;
    }

After this changes got the following error. how to solve this.

Fatal error: Call to a member function getSetIds() on a non-object in /var/www/html/app/code/core/Mage/Catalog/Model/Layer.php on line 306 

Thanks.

1 Answer 1

1

You should replace

$collection = Mage::getModel('catalog/product')->getCollection()
                        ->addAttributeToSelect('*')
                        ->addAttributeToFilter('price', array('gteq' => $startprice))
                        ->addAttributeToFilter('price', array('lteq' => $endprice))
                        ->getData();

with

$collection = Mage::getModel('catalog/product')->getCollection()
                        ->addAttributeToSelect('*')
                        ->addAttributeToFilter('price', array('gteq' => $startprice))
                        ->addAttributeToFilter('price', array('lteq' => $endprice));

Method getData() returns array, non-object value

0

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.