Post by Baco » Tue May 01, 2012 6:22 pm

Hi, programmer's and all, who use OC...
Can't display $product_total; in 'category superfish' module... here is some code for request:

Code: Select all

public function getTotalproductsByCategoryId($category_id = 0) {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND p2c.category_id = '" . (int)$category_id . "'");

		return $query->row['total'];
	}
and in conroller add:

Code: Select all

if( $this->config->get('category_superfish_counter')>0) $product_total = " (".$this->model_catalog_category_superfish->getTotalproductsByCategoryId($result['category_id']).")";
				else $product_total = '';
							
			if($parent_id==0) $output .= '<a href="' . $this->url->link('product/category','path=' . $new_path)  . '"><b>'.$result['name'].'</b></a>';
			elseif($parent_id != $this->parent_id) $output .= '<a href="' . $this->url->link('product/category','path=' .  $new_path)  . '">'.$result['name'].' (' . $product_total . ')'.'</a>';
			else $output .= '<a href="' . $this->url->link('product/category','path=' .  $new_path)  . '">&nbsp;&nbsp;&nbsp;&nbsp;'.$result['name'].' (' . $product_total . ')'.'</a>';
Where is error ? How to display total product's ?
Thank's for answer.

Newbie

Posts

Joined
Fri Apr 20, 2012 5:22 am
Who is online

Users browsing this forum: No registered users and 4 guests