Post by ghostdog87 » Thu Jul 19, 2012 5:08 am

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

Active Member

Posts

Joined
Wed Mar 07, 2012 12:31 pm

Post by grgr » Thu Jul 19, 2012 3:03 pm

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.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by ghostdog87 » Thu Jul 19, 2012 10:47 pm

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

Active Member

Posts

Joined
Wed Mar 07, 2012 12:31 pm

Post by grgr » Fri Jul 20, 2012 12:06 am

Not tested but should work:

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by ghostdog87 » Fri Jul 20, 2012 12:11 am

Awesome, i really appreciate your help

tested and working :)

thanks

Active Member

Posts

Joined
Wed Mar 07, 2012 12:31 pm

Post by my55fj » Sat Aug 04, 2012 11:23 am

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

Newbie

Posts

Joined
Mon Jul 02, 2012 10:56 am

Post by grgr » Mon Aug 06, 2012 5:30 am

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.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by stokeyblokey » Sun Nov 15, 2015 12:58 am

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! ;D

Stokey


User avatar
Active Member

Posts

Joined
Sat Aug 31, 2013 10:19 pm
Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 196 guests