Originally Posted by
earth-friendly
I have discovered a problem.
If you go to my website,
http://www.kosher4health.com, and go to the "Snacks" category, and then click on the checkbox for "Gluten Free", and then at the top right, instead of going to the next page, click "View All",
then I get: "There are no products to list in this category." even though there are products.
There is a debug file, and it has a bunch of stuff, but I think the main thing is that it is trying to divide by zero in split_page_results.php, on line 100. (I can give you the complete debug file if that will be helpful.)
This is line 100:
Code:
$this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);
This means that
Code:
$this->number_of_rows_per_page
is zero.
Higher up in the file we have:
Code:
$this->number_of_rows_per_page = $max_rows;
and a little above that we have:
Code:
if ($page == 'all') {
$this->page_all = true;
$override = $db->Execute($query);
$max_rows = $override->RecordCount();
}
So it looks like the query is not returning any results.
I'm not sure where I should go from here. I could work in my test site, and turn on debugging for sql statements. Or, does anyone have any ideas about what might be going wrong and how to fix it?
I am using zen-cart 1.5.5a, and the Winchester Responsive template.
I did my best to modify split_page_results.php for this mod, but there were some significant differences between this file and my version, probably because of both 1.5.5a and Winchester Responsive.
Thanks in advance for any help with this issue!
I have sort of figured this out, but not sure if my solution makes total sense.
The file I worked with is includes/modules/MYTEMPLATE/dynamic_filter.php
The issue seems to be in the HAVING part of the query:
Code:
$having .= ' FIND_IN_SET("' . $key . addslashes($value) . '", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))';
When I go to my website and click on the snacks category,
http://www.kosher4health.com/snacks-c-1.html
and then I click on "Gluten Free" to filter by that,
everything works fine. The value of $having at that point is:
Code:
HAVING (
FIND_IN_SET("GlutenFreeGluten Free", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))
However, if I then click on the "View All" link in the top right (instead of going to a particular page number), it says there are no products to list in this category. The query that is being run returns no records. And, the value of $having at that point is:
Code:
HAVING (
FIND_IN_SET("GlutenFreeGluten%20Free", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))
So in other words, the option value that it is searching for in the database, after clicking on "Gluten Free", is "Gluten Free".
But after clicking on "View All", the option value that it is searching for is "Gluten%20Free".
I also noticed that the urls are a bit strange:
After clicking on the checkbox for "Gluten Free", the url is:
Code:
http://www.mydomainname.com/snacks-c-1.html?main_page=index&cPath=1&fltGlutenFree%5B%5D=Gluten+Free
and after clicking on "View All", the url is:
Code:
http://www.mydomainname.com/snacks-c-1.html?fltGlutenFree%5B%5D=Gluten%2520Free&sort=20a&page=all
It looks like extra encoding happens during this process.
The solution I came up with in my test site is to remove both a space and "%20" in $value, and then in the db search, also remove spaces from the products_options_values_name, in the same way that spaces are being removed from the search on products_options_name.
So, I replaced :
Code:
$having .= ' FIND_IN_SET("' . $key . addslashes($value) . '", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), pov.products_options_values_name)))';
with
Code:
$having_value = str_replace(" ","",$value);
$having_value = str_replace("%20","",$having_value);
$having .= ' FIND_IN_SET("' . $key . addslashes($having_value) . '", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), REPLACE(pov.products_options_values_name, " ", ""))))'
And now, after clicking on the checkbox for Gluten Free, the value of $having is:
Code:
HAVING (
FIND_IN_SET("GlutenFreeGlutenFree", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), REPLACE(pov.products_options_values_name, " ", ""))))
and after clicking on "View All", the value of $having is:
Code:
HAVING (
FIND_IN_SET("GlutenFreeGlutenFree", GROUP_CONCAT(CONCAT(REPLACE(po.products_options_name, " ", ""), REPLACE(pov.products_options_values_name, " ", ""))))
I haven't put this on my live site yet. I was hoping that perhaps Design75, you could please look it over to make sure it is a reasonable change.
Also, I wonder if anyone else has had this problem, or if it has to do with the template I am using.
Thanks in advance for your help with this!!
Bookmarks