Page 1 of 1
Featured Products and 0 Quantity
Posted: Thu Jul 19, 2012 5:08 am
by ghostdog87
Hi, i have a question about featured products. im adding this products to the featured list and they display in the module in the front end, but whenever someone buys one of this products and the stock or quantity is 0, the products are still displaying in featured module
Any ideas on how to automatically remove featured products with quantity = 0
Thanks in advance
Re: Featured Products and 0 Quantity
Posted: Thu Jul 19, 2012 3:03 pm
by grgr
Edit ../catalog/controller/module/featured.php
find:
Code: Select all
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
and change so it loks like this:
Code: Select all
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if ($product_info['quantity'] > 0){
Don't forget to add a closing brace ( } )to the bottom of the if statement.
Re: Featured Products and 0 Quantity
Posted: Thu Jul 19, 2012 10:47 pm
by ghostdog87
Hi, thanks for the info
Is there any possibility to make this a vqmod?, im reluctant to make direct modification to files as there is a programmer working on a multiseller platform and i dont want to mess things up
Re: Featured Products and 0 Quantity
Posted: Fri Jul 20, 2012 12:06 am
by grgr
Not tested but should work:
Re: Featured Products and 0 Quantity
Posted: Fri Jul 20, 2012 12:11 am
by ghostdog87
Awesome, i really appreciate your help
tested and working
thanks
Re: Featured Products and 0 Quantity
Posted: Sat Aug 04, 2012 11:23 am
by my55fj
Just follow up question on this topic.... now that the products are hidden/removed from displaying then this makes the category counts factually incorrect as these do not ignore any products that have a 0 quantity.
Obviously the counts look at the data somewhere to see whether products are 'enabled/active', thus assume it should be able to check whether there is a quantity > 0?
Has anyone done or are able to assist in the editing of this category count?
Thanks in advance
Re: Featured Products and 0 Quantity
Posted: Mon Aug 06, 2012 5:30 am
by grgr
You need to edit the relevant query (getTotalProducts) in ../catalog/model/catalog/product.php
edit:
Code: Select all
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
and add a quantity clause:
Code: Select all
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.quantity > '0' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";
At a guess, not tried it.
However, i would suggest doing this actually makes the count incorrect as if you have 10 products in a category and one of them is out of stock, you still have 10 products in the category, it's just one is out of stock at the moment so you may or may not be able to buy it, it's still 10 products and not 9.
Re: Featured Products and 0 Quantity
Posted: Sun Nov 15, 2015 12:58 am
by stokeyblokey
grgr, thank you for this fix!
I managed to implement it on several other modules but the Featured one was coded differently to them and I (being a non-coding shopkeeper) just couldn't get it to work. All fixed up now, another great job by grgr!
