Post by robertiulianstoica » Fri May 31, 2013 4:38 pm

For all of you who are interested in getting the category filters from the products loaded in the category, not from the table category_filter you must go to catalog/model/catalog/category.php and modify the function "getCategoryFilters" by replacing

Code: Select all

$query = $this->db->query("SELECT filter_id FROM " . DB_PREFIX . "category_filter WHERE category_id = '" . (int)$category_id . "'");

Code: Select all

$query = $this->db->query("SELECT pf.filter_id FROM " . DB_PREFIX . "product p LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id) LEFT JOIN product_filter pf ON (p.product_id = pf.product_id) WHERE p2c.category_id = '" . (int)$category_id . "'");
DONE! Now your filters will load in every category depending on the products contained. You no longer need to insert filters into categories, neither will they apear if there are no products returned by the filter.

Ps: if anyone is interested, i will later provide a code to select filters depending on the filtered products loaded in the category.



New member


Tue May 07, 2013 8:42 pm

Post by Spiritcraft » Mon Jul 22, 2013 9:29 pm

What a time saver this code was. Thank you Robert.



Sun Jun 23, 2013 12:30 pm
Who is online

Users browsing this forum: No registered users and 4 guests