Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Automatically hide out of stock products in opencart 1.5.6

For out of stock products you can use stock statuses to inform customer that you had that product in stock but you dont anymore, however some merchants would preffer to not display at all the products they dont have in stock, if you wish to do that, here is a simple modification you can do to obtain it.

Edit the file catalog/model/catalog/product.php and inside it seach for the code:

pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1'

You will find it 3 times, and each time replace it with the code:

pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.quantity > '0'

Then save the file and done, your out of stock products will not display anymore.

If you use vqmod and do not wish to edit your core file just download this vqmod from here , drop the xml file from the archive in your store's vqmod/xml folder and you obtained the modification even faster.

Posted by Flo

13 Comments To "Automatically hide out of stock products in opencart 1.5.6"

Fayas On 01 Dec 2016
Thanks, it worked swiftly. Now, How can i bring it back ? redo is not working Reply to this comment
someone On 17 Oct 2016
This fix works great! It worked for me on OC 2.3.0.2 with no problem. Elegant solution that makes sense. thank you for posting! Reply to this comment
Akash On 27 Jun 2016
Thanks I am newbe for opencart its work for me thanks a lot Reply to this comment
Catalin On 10 Mar 2016
If i want to see only as admin, products that have stock 0 ( out of stock ) ? Can you change the code pls ? Reply to this comment
Flo On 10 Mar 2016
You can allready see stock in admin.
Eugene On 25 Apr 2015
IMHO, much better solution is just to move out of stock product to the end of list. This work fine for me and don't mess SEO. Reply to this comment
Marcelo Costa de aquino On 25 Mar 2015
How i do display "out of Stock"? Thanks Reply to this comment
Flo On 04 Mar 2015
I dont understand how that would go. If you dont want customer to access those products why would you have them in google?Wouldnt the customer be able to access them then? Reply to this comment
Draganche On 04 Mar 2015
Yes, it can be helpful, but as Sam says it messes up SEO and all out of stock products are not visible. Is there any solution to hide out of stock products from category list, but still be available in site or Google search? Reply to this comment
Sam On 04 Jan 2015
Nice mod, but it messes up SEO, it hides it from Google too, I only want the out of stock products to be invisible to the customer, so the URL's must remain, so really only the categories and search need to be hidden, not the actual products. Is there as way to do this, there is some mods on opencart market, but they don't work properly, your mod works well, but wrong feature for me. Reply to this comment
amy On 23 Jun 2014
Fantastic worked first time no problem Reply to this comment

Write a comment

Your Name:


Enter the code in the box below:

Your Comment:
Note: HTML is not translated!