We are trying to figure out if there is a Magento setting or another way of making sure that any products on our e-commerce site that are uploaded with a price of 0 are set to out of stock, so then they will not be visible on the front end

I have already found the setting that Sets out of stock products to be disabled,

So I'm trying to figure out how to make all products with price = 0, set to out of stock


Only way could think of doing this is by cron which would look something like this. hope this helps

public function setOutOfStock()
    $collection = Mage::getResourceModel('cataloginventory/stock_item_collection');
    $collection->addFieldToFilter('qty', array('eq' => 0));

    foreach($collection as $item) {
        $item->setData('is_in_stock', 0);

Why not just set stock quantity to 0 and disable backorders? Products with 0 stock will be automatically be set to Out of Stock by Magento (at least in Magento 2, I'm sure it's the same in 1)

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.