Post by JNeuhoff » Tue Jun 30, 2009 8:58 pm

The following database queries in /catalog/model/catalog/product.php don't always match up in the number of products returned. This bug exists both in Opencart 1.2.8 and 1.2.9.
  • getProductsByCategoryId
    getTotalProductsByCategoryId
The 2 queries use different WHERE clauses. I suggest to fix the getTotalProductsByCategoryId by using the same WHERE-clause in there as in getProductsByCategoryId.

E.g. in Opencart 1.2.8 it would be something like this:

Code: Select all

	public function getTotalProductsByCategoryId($category_id = 0) {
		$sql = "SELECT COUNT(*) AS total FROM product_to_category p2c LEFT JOIN product p ON (p2c.product_id = p.product_id) LEFT JOIN stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1' AND p.date_available <= NOW() AND ss.language_id = '" . (int)$this->language->getId() . "' AND p2c.category_id = '" . (int)$category_id . "'";
		$query = $this->db->query( $sql );
		
		return $query->row['total'];
	}


Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 16 guests