Trying to find product collection with custom attribute option 'Show Room' as filter and out of stock that is 'is_in_stock' attribute is equal to 0

 $sAttributeName = 'sale_by';
    $mOptionValue = 'Show Room';
    $_get_show_room_sale_products = Mage::getModel('catalog/product')->getCollection();
    ->addAttributeToFilter('is_in_stock', 0)
        'eq' => Mage::getResourceModel('catalog/product')

But I am getting following error

Fatal error: Call to a member function getBackend() on a non-object in..../app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 816

What am i miss here.Please advice


For attribute filter -

$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToFilter('your-attribute', array('eq' => 'attr-value'));

For out of stock filter

                ->addAttributeToFilter('is_in_stock', array('eq' => 0));
  • 1
    I have try with same but it return me all product
    – Mitul
    Dec 8 '15 at 11:44

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.