its only one file changes
catalog\model\catalog -> and replce product.php
I hope that this is it.
THIS is repair of price_filter archive pack!
Attachments
My themes:
Fleen Theme
My vqmods:
Remove description tab - Remove related products tab - Remove title from category page
this
if (!empty($data['filter_filter'])) {
$zaznamu_pole = count($implode);
$sql .= " HAVING COUNT(*) = " . $zaznamu_pole . "";
}
replace with this
if (!empty($data['filter_filter'])) {
$gquery = "SELECT COUNT(*) AS total FROM (SELECT COUNT(*) FROM filter WHERE filter_id IN (" . implode(',', $implode) . ") GROUP BY filter_group_id) as groupstotal";
$gsql = mysql_query($gquery);
$fgroup_count = mysql_fetch_array($gsql);
$sql .= " HAVING COUNT(*) = " . $fgroup_count['total'] . "";
}
in function GetProducts and getTotalProducts, so it 2x replace this code above
but still is here problem with product which has two or more filter options of the same filter group.. it mean product with color red and blue and more
My themes:
Fleen Theme
My vqmods:
Remove description tab - Remove related products tab - Remove title from category page
No more problem with product with 2 or more filter options in the same filter group!
For example of filtring:
COLOR MATERIAL <-filter groups
blue metal
red wood <-filter options
white
between all colors will be logical OR, the same between material type. Between color and material logical AND..
I hope that more bugs will not be detected..
For install: 1) product.php
rewrite catalog/model/catalog/product.php
for install whole pack: Just coppy all to root/catalog direcotry..
This was maded only for 1.5.5 and 1.5.5.1 version, on clean install..
Enjoy
Attachments
who has price filter already and needed to correct filtring. Options in the same group is like a OR and options between groups are AND
Thanks.
My themes:
Fleen Theme
My vqmods:
Remove description tab - Remove related products tab - Remove title from category page
My themes:
Fleen Theme
My vqmods:
Remove description tab - Remove related products tab - Remove title from category page
<search position="before" index="2"> example..
Anyway.. i compilate all change, you can try make it work. What i mentioned, almost of file modification didnt execute changes inside
and <file name="catalog/model/catalog/category.php"> didnt work without index equal 2 or more then 2 <search position="before" index="2">
maybe it should help..
Attachments
IT DOESNT WORK!
This is model file:
Code: Select all
public function getCategoryPriceRange($category_id) {
$minmax = array();
$query = 'SELECT MIN(price) AS min, MAX(price) AS max FROM ' . DB_PREFIX . 'product P
join ' . DB_PREFIX . 'product_to_category POC
on POC.product_id = P.product_id
where POC.category_id = ' . (int)$category_id . ' AND P.status = 1' ;
$results = $this->db->query($query);
$minmax = $results->row;
if(empty($minmax['min']) and empty($minmax['max'])){
return null;
}
$minmax = array(
'minimum' => floor($minmax['min']),
'maximum' => floor($minmax['max'])
);
return $minmax;
}
Can you do something in this module so it uses the opencart's manufactures attribute as filter?
(filter_group_color.filter = 'red' OR filter_group_color.filter = 'blue' OR filter_group_color.filter = 'green') AND filter_group_size.filter = 'large' .
So I made these changes in catalog\model\catalog\product.php - same changes to functions getProducts() and getTotalProducts():
replace (line 81):
Code: Select all
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)";
Code: Select all
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf_1 ON (p2c.product_id = pf_1.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)";
$fid_array = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$fid_array[] = (int)$filter_id;
}
$query = $this->db->query("SELECT COUNT(DISTINCT filter_group_id) AS num_fgid FROM " . DB_PREFIX . "filter_description WHERE filter_id IN(" . implode(',', $fid_array) . ")");
if(!empty($query->row['num_fgid'])) {
for ($thisgrp = 2; $thisgrp <= $query->row['num_fgid']; $thisgrp++) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf_" . $thisgrp . " ON (p2c.product_id = pf_" . $thisgrp . ".product_id) ";
}
}
Code: Select all
$implode = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$implode[] = (int)$filter_id;
}
$sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")";
Code: Select all
$query = $this->db->query("SELECT fd.filter_group_id, fd.filter_id, n.num_sel_filters_in_grp FROM " . DB_PREFIX . "filter_description fd left join (SELECT filter_group_id, count(filter_group_id) as num_sel_filters_in_grp FROM " . DB_PREFIX . "filter_description WHERE filter_id IN (" . implode(',', $fid_array) . ") GROUP BY filter_group_id) as n on fd.filter_group_id = n.filter_group_id WHERE filter_id IN (" . implode(',', $fid_array) . ") GROUP BY fd.filter_group_id, fd.filter_id");
if ($query->num_rows) {
$g_count = 0;
$f_count = 0;
$last_fgid = -1;
foreach ($query->rows as $frow) {
$f_count += 1;
if ($frow['filter_group_id'] != $last_fgid) {
$g_count += 1;
$f_count = 1;
$last_fgid = $frow['filter_group_id'];
$sql .= " AND (pf_" . $g_count . ".filter_id = " . $frow['filter_id'];
}
else {
if ($frow['num_sel_filters_in_grp'] > 1) {
$sql .= " OR pf_" . $g_count . ".filter_id = " . $frow['filter_id'];
}
}
if ($f_count == $frow['num_sel_filters_in_grp']) {
$sql .= ")";
}
}
}
Code: Select all
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf ON (p2c.product_id = pf.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (pf.product_id = p.product_id)";
Code: Select all
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf_1 ON (p2c.product_id = pf_1.product_id) LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id)";
$fid_array = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$fid_array[] = (int)$filter_id;
}
$query = $this->db->query("SELECT COUNT(DISTINCT filter_group_id) AS num_fgid FROM " . DB_PREFIX . "filter_description WHERE filter_id IN(" . implode(',', $fid_array) . ")");
if(!empty($query->row['num_fgid'])) {
for ($thisgrp = 2; $thisgrp <= $query->row['num_fgid']; $thisgrp++) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_filter pf_" . $thisgrp . " ON (p2c.product_id = pf_" . $thisgrp . ".product_id) ";
}
}
Code: Select all
$implode = array();
$filters = explode(',', $data['filter_filter']);
foreach ($filters as $filter_id) {
$implode[] = (int)$filter_id;
}
$sql .= " AND pf.filter_id IN (" . implode(',', $implode) . ")";
Code: Select all
$query = $this->db->query("SELECT fd.filter_group_id, fd.filter_id, n.num_sel_filters_in_grp FROM " . DB_PREFIX . "filter_description fd left join (SELECT filter_group_id, count(filter_group_id) as num_sel_filters_in_grp FROM " . DB_PREFIX . "filter_description WHERE filter_id IN (" . implode(',', $fid_array) . ") GROUP BY filter_group_id) as n on fd.filter_group_id = n.filter_group_id WHERE filter_id IN (" . implode(',', $fid_array) . ") GROUP BY fd.filter_group_id, fd.filter_id");
if ($query->num_rows) {
$g_count = 0;
$f_count = 0;
$last_fgid = -1;
foreach ($query->rows as $frow) {
$f_count += 1;
if ($frow['filter_group_id'] != $last_fgid) {
$g_count += 1;
$f_count = 1;
$last_fgid = $frow['filter_group_id'];
$sql .= " AND (pf_" . $g_count . ".filter_id = " . $frow['filter_id'];
}
else {
if ($frow['num_sel_filters_in_grp'] > 1) {
$sql .= " OR pf_" . $g_count . ".filter_id = " . $frow['filter_id'];
}
}
if ($f_count == $frow['num_sel_filters_in_grp']) {
$sql .= ")";
}
}
}
Regards.
to be true the filter module implemented in 1.5.5.x is the best by far than all extensions out there, no offence meant for extension creators, are all good but the new filter that comes with opencart is way faster, simple, etc. Despite the fact that are many people that are saying is redundant to make another set of rules for filters instead of using atributes, maybe so but in this way is more flexible. Anyway midgette your solution is the best, clean and easy, only one file to edit to keep it simple. Maybe they will implement your solution in next releases to complete the filter module functionality.
Best regards man, really awesome work there !
There is a small change i wan't to add for those who want a live filter (to get rid of filter button), there is a small change in /catalog/view/theme/default/template/module/filter.tpl
Code: Select all
<script type="text/javascript"><!--
$(document).ready(function() {
$('.box-filter li ul li input[type=\'checkbox\']').live('click', function() {
filter = [];
$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
filter.push(this.value);
});
location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
});
//--></script>
http://www.opencart.com/index.php?route ... n_id=11707
his work but the problem is,when user click the product ridirect from the hompage where is inside the latest module filters function not show/not come out is mean filters dont have in that product.. but if user click the product from categorie filters will show.... for sure....1. Go to Catalog > Filters and select Insert to create a filter group. Assign a filter group name (e.g. Color) and add filter name values (e.g. Blue, Red, Yellow).
2. Go to Catalog > Categories and Edit a category. Under the Data tab add the filters you want to be able to apply to that category (e.g. Color > Blue, Color > Red).
3. Go to Catalog > Products and Edit a product. Under the Links tab add the filters which apply to the product (e.g. Color > Blue). Apply to as many products as applicable.
4. Go to Extensions > Modules > Filter. If not installed select Install. Click Edit. Click the Add Module button and under Layout select Category and set Status to Enabled. Set whatever position and sort order you would like.
Filters module will work id user go from here :
cateforie>perfume>gucci>product model.
Filters module not work if user from here:
homepage>product model.
And for more deteil please come my store here :http://perfumelovers.net/
Please anyone can fix this??.. tanks in advance
I am trying to modify product.php according to the changes provided by midgette and I get a Syntax MySQL error. Should I change other files ? Who can provide me these changes in a zip file ? I am using opencart version 1.5.5.1
Many thanks
Nicusor
On lines 110 and 537 I changed
Code: Select all
count(filter_group_id)
Code: Select all
(count(filter_group_id)/count(DISTINCT language_id))
Notice: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Error No: 1064
SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_product_to_category p2c LEFT JOIN oc_product_filter pf_1 ON (p2c.product_id = pf_1.product_id) LEFT JOIN oc_product p ON (p2c.product_id = p.product_id) LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '2' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND p2c.category_id = '18' AND (pf_1.filter_id = 1 in /home/superlap/public_html/opencart/system/database/mysql.php on line 50
Users browsing this forum: No registered users and 135 guests