Magento News

 

In Magento, how do you filter a product collection by the manage_stock field?

I’ve built an inventory update script – where I fetch a product collection in Magento, and iterate through the result set, updating product inventory (based on a separate inventory feed) as I go.

I can fetch the product collection no problem.

However, I only want to get products which have the “Manage Stock” field (a dropdown in the admin under the “inventory” tab) set to “yes”.

So I tried:

// get all magento catalog products with "manage stock" field set to yes
$items = Mage::getModel('catalog/product')->getCollection();
$items
 ->addAttributeToSelect(array(
  'id',
  'sku'
 ))
 ->addFieldToFilter(array(
  array(
   'attribute' => 'manage_stock',
   'eq' => '1'
  ),
 ));

But, getting an error:

Invalid attribute name: manage_stock.

Help?
Matt

In Magento, how do you filter a product collection by the manage_stock field?

Possibly Related Posts:


 

Leave a Reply