Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : Call to undefined method addAttributeToFilter()

I have made my Magento Model :

<?php

class Kiwi_SliderBoard_Model_Resource_Slider_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{

    protected function _construct()
    {
         $this->_init("sliderboard/slider");

    }

}

Whene i try to use it on my block :

class Kiwi_SliderBoard_Block_Slider extends Mage_Catalog_Block_Product_Abstract {

    public  function getSlider ()
    {
        $slider= Mage::getModel('sliderboard/slider')
                 ->getCollection()
                 ->addAttributeToFilter('status', array('eq' => 1));
        return  $slider;
  }

}

I got this Error !

Fatal error: Call to undefined method Kiwi_SliderBoard_Model_Resource_Slider_Collection::addAttributeToFilter() in C:\wamp\www\ce_1.6.2.0\app\code\local\Kiwi\SliderBoard\Block\Slider.php on line 8

Can you help !
Thanks

like image 708
t.c Avatar asked Nov 09 '12 09:11

t.c


1 Answers

addAttributeToFilter();

is only used for the EAV Collections like products, customers, etc.

for all the other collections just use :

addFieldToFilter();
like image 188
t.c Avatar answered Oct 31 '22 11:10

t.c