Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • add 'in stock' filter in product collection in magento

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.42k
    Comment on it

    Add 'in stock' filter in product collection in magento

    To get product that is in stock apply the below filter to your product collection -

    $productDetails    = Mage::getModel('catalog/category')->load($cat_id)->getProductCollection()->addAttributeToSelect('*');
    $productDetails -> addAttributeToFilter('visibility', array('in' => array(4) ));
    $productDetails -> addAttributeToFilter('status', array('in' => array(1) ));
    $productDetails->joinField('is_in_stock',
                    'cataloginventory/stock_item',
                    'is_in_stock',
                    'product_id=entity_id',
                    'is_in_stock=1',
                    '{{table}}.stock_id=1',
                    'left');      
    

    Here we apply three filter - 'visibility' , 'status' , and finally our 'In stock' filter...

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: