1

I am using addStoreFilter with my custom collection but it won't work.

it gives null result.

My DB column name is store_id

for specific store it store like 1,2,3 abd for all store it will store 0

code is as below.

 $collection=Mage::getModel('productline/productline')->getCollection()
    ->addFieldToFilter('status','1')
    ->setOrder('sort_order','ASC')
    ->addStoreFilter();

Please help on this.

3

You need to use it like below.

$storeId = Mage::app()->getStore()->getStoreId();
$collection=Mage::getModel('productline/productline')->getCollection()
    ->addFieldToFilter('status','1')
    ->setOrder('sort_order','ASC')
    ->addFieldToFilter('store_id',
        array(
            array('finset'=> array('0')),
            array('finset'=> array($storeId)),
        )
    ));

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.