Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Can Magento hide products (or atributes for configurable products) when they are ‘out of stock’? 
 
medic
Sr. Member
 
Total Posts:  173
Joined:  2007-10-30
Sydney
 

I thought Magento could do this, can it?

Say if i have a configurable product with different shirt sizes, and the small size sell out, they are not being removed from the drop down menu.

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dan1
Jr. Member
 
Total Posts:  1
Joined:  2008-07-25
 

I would like to know this as well. My store sells many items that only 1 is available. It would really make a difference if the item was taken off the site when it sold.

 
Magento Community Magento Community
Magento Community
Magento Community
 
medic
Sr. Member
 
Total Posts:  173
Joined:  2007-10-30
Sydney
 

does not look like there is an answer for this.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

@medic - Magento will only display the simple products options for the products that are in stock.

 
Magento Community Magento Community
Magento Community
Magento Community
 
medic
Sr. Member
 
Total Posts:  173
Joined:  2007-10-30
Sydney
 

@ YoavKutner

Thank you for your reply.

That is what I thought would happen.

However, there seems to be a problem with the simple product inventory not reducing when an order has been placed via a configurable product.
For some reason it seems to reduce the configurable product inventory even though the configurable product should not have any ‘inventory’.

I’ll test it out again.

ps. For some reason your post says that it was posted 11 months ago. Strange. *edit* post date back to normal now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

@medic - Please test on your end as I am not aware that we have issues in the latest Magento version. Please open a bug on our bug tracking system if you do feel there is a bug.

Thanks

yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
medic
Sr. Member
 
Total Posts:  173
Joined:  2007-10-30
Sydney
 

I have tested this with a fresh install and my modified version (1.1.2)

This is what I did:

Created a simple product with 2 units (I made this visible from the front end so I could test)
Created a configurable product and linked up the simple product.

If i place an order from the simple product page - the inventory reduces and the product does go ‘out of stock’.

If I place an order from the configurable product - the inventory of the simple product will remain the same.
The drop down menu on the configurable product page will still show the simple product.

I can only order the 2 units on the one order - but after the order has been placed I can go back and order another 2 units.

I have tried different combinations and tried using the quick simple product creator and nothing seems to work. I know someone else has had this same problem.
They replied to my other thread.

I have posted the bug, but have not had any answer. It has become a big problem because it is holding up our site launch.

 
Magento Community Magento Community
Magento Community
Magento Community
 
medic
Sr. Member
 
Total Posts:  173
Joined:  2007-10-30
Sydney
 

I just reinstalled version 1.1.2 with the Sample Products.

My first question is - Why does the configurable product have an inventory amount? It is showing that they have an inventory of 100.

When you place an order - the inventory is reduced from the configurable product, not the simple product attached.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

@medic - The issue you reported was fixed and an update will be made available in the next upcoming release.

Thanks for your help

yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
Crazy Serb
Jr. Member
 
Total Posts:  12
Joined:  2008-07-23
 

back to the original question then - how would I hide simple products that are out of stock from being shown in catalog?

 
Magento Community Magento Community
Magento Community
Magento Community
 
reststop
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2008-05-22
 

Is it possible to have a script run via a cron job, which will “Disable” a product if the quantity is 0?

This would leave the functionality of in-stock/out-of-stock the way it is, but allow stores to make products go away when they are sold-out.
Well, not go away, but become unavailable.

I don’t know how functional the cron task-list is, or how easy something like this could be done.

Another option would be to setup the out-of-stock notification to a special address, which could then process the notification and fire a script, or a selected procedure to be performed.  Then you just need a script or procedure to disable the product when the notification is received.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Crazy Serb
Jr. Member
 
Total Posts:  12
Joined:  2008-07-23
 

that sounds more like a workaround… working around the issue here.

I’m actually thinking of just locating that part of the code (probably the SQL WHERE query somewhere, in some shape or form) where I can just add the condition to query those items whose stock is not 0 to be displayed on the front end…

where would I find that, I don’t know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ajitray
Jr. Member
 
Total Posts:  2
Joined:  2008-10-10
 

back to the original question then - how would I hide simple products that are out of stock from being shown in catalog?

Open file
/app/design/frontend/YOUR_TEMPLATE/default/template/catalog/product/list.phtml

look for You will see it in two locations. Once for the list view and once for the grid view
<?php if($_product->isSaleable()): ?> (line 99 for me)

change it to
<?php if($_product->isInStock()): ?>

Done . smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
colinmollenhour
Member
 
Avatar
Total Posts:  50
Joined:  2009-05-01
 
aMANinDESIGN - 27 February 2009 09:14 AM

I moved where you added this code so it not only takes away the add to cart option but completely hides the entire product.

Unfortunately this method has some serious drawbacks, such as it breaks pagination.. If you have 3 out of 100 items in a category in stock, then you will have many empty pages! Same goes for searches.

Here is a solid solution that has the same effect without breaking the pagination, searches, etc.. It took much hair-pulling to figure this out so I posted it to my blog.

http://colin.mollenhour.com/2009/06/hiding-out-of-stock-items-in-magento/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 
colinmollenhour - 02 June 2009 02:56 PM

aMANinDESIGN - 27 February 2009 09:14 AM
I moved where you added this code so it not only takes away the add to cart option but completely hides the entire product.

Unfortunately this method has some serious drawbacks, such as it breaks pagination.. If you have 3 out of 100 items in a category in stock, then you will have many empty pages! Same goes for searches.

Here is a solid solution that has the same effect without breaking the pagination, searches, etc.. It took much hair-pulling to figure this out so I posted it to my blog.

http://colin.mollenhour.com/2009/06/hiding-out-of-stock-items-in-magento/

Thank youuuuuu!!!! :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
colinmollenhour
Member
 
Avatar
Total Posts:  50
Joined:  2009-05-01
 

Actually, I have since fixed the code to work with configurable products.. For some reason Magento updates the stock_status when a configurable product goes out of stock, but not is_in_stock.. Here is the updated version:

class Lucky_InStockOnly_Model_Observer {
  
public function addInStockOnlyFilter($observer){
    $observer
->getEvent()->getCollection()
      ->
joinField('stock_status','cataloginventory/stock_status','stock_status',
        
'product_id=entity_id', array('stock_status' => Mage_CatalogInventory_Model_Stock_Status::STATUS_IN_STOCK))
    ;
  
}
}

The blog post has been updated as well.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2