Post by fido-x » Sun Oct 04, 2009 5:58 pm

There is a bug in the query that counts the number of special offer products, in that, ALL special offer products are counted - regardless of customer group.

Fix by replacing by replacing the existing getTotalProductSpecials() function (catalog/model/catalog/product.php - lines 297 to 311) with:

Code: Select all

public function getTotalProductSpecials() {
	if ($this->customer->isLogged()) {
		$customer_group_id = $this->customer->getCustomerGroupId();
	} else {
		$customer_group_id = $this->config->get('config_customer_group_id');
	}		

	$query = $this->db->query("SELECT COUNT(DISTINCT ps.product_id) AS total FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_special ps ON (p.product_id = ps.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) AND ps.product_id NOT IN (SELECT pd2.product_id FROM " . DB_PREFIX . "product_discount pd2 WHERE p.product_id = pd2.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW()))) AND ps.customer_group_id = '" . (int)$customer_group_id . "'");

	if (isset($query->row['total'])) {
		return $query->row['total'];
	} else {
		return 0;	
	}
}

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: Baidu [Spider] and 10 guests