When selecting a category to display the products, it currently it goes to "Rating: Highest" automatically. Not sure why it's selecting that instead of "Default"!
Is "Rating: Highest" set somewhere? Is there an easy fix to revert it back to "Default" instead?
Thanks in advance.
Probably in your cookies?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
The only additional information I can provide is that I just found out that my host has decided to upgrade their version of SQL to v8 and have told me that OC2.3.0.2 was previously using SQL v5.7, and may no longer be fully compatible. If manually change from the dropdown to Default, it works fine. However if I change it from NAME (A-Z), I get the following error that is attributed to the change in the SQL version.ADD Creative wrote: ↑Thu Feb 22, 2024 11:17 pmThe default sort order is hard code. Is your theme or any extensions changing it?
Code: Select all
Fatal error: Uncaught Exception: 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 'ORDER BY LCASE(pd.name) ASC, LCASE(pd.name) ASC LIMIT 0,20' at line 1<br />Error No: 1064<br />SELECT p.product_id, (SELECT AVG(rating) AS total FROM oc_review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM oc_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM oc_product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special FROM o in /home/anoth305/public_html/shop/system/library/db/mysqli.php on line 40
The only other solution that I can think of is a VQMOD that can rewrite the syntax to prevent the above error, to make it compatible with SQL 8. Unfortunately that is out of my technical area. Any ideas?
For MySQL 8 you may have to remove NO_ZERO_DATE from the sql_mode.
Try making it the same as this line.
https://github.com/opencart/opencart/bl ... li.php#L18
I can't do that sorry, I have ZERO experience with SQL stuff, I don't want to screw anything up further. I think it's just barely hanging on since they upgraded to the new version of SQL 8.ADD Creative wrote: ↑Fri Feb 23, 2024 8:01 amCould be you have something modifying your SQL query. The error seems to have "LCASE(pd.name) ASC" twice. Although that just could be the way the error was formatted.
For MySQL 8 you may have to remove NO_ZERO_DATE from the sql_mode.
Try making it the same as this line.
https://github.com/opencart/opencart/bl ... li.php#L18
Ideally a xml mod that changes the default sort criteria to Default rather than Rating would be ok. I can work with that, but no idea where in the code Rating is hard wired to be the default.
https://www.opencart.com/index.php?rout ... _license=0
There is also this extension which promises to fix the problem, looks more promising, but won't know until I purchase it:
https://www.opencart.com/index.php?rout ... rt%20order
Hoping there's another solution.
First in catalog/controller/product/category.php line 21.
https://github.com/opencart/opencart/bl ... ry.php#L21
Then in catalog/model/catalog/product.php line 177.
https://github.com/opencart/opencart/bl ... t.php#L177
Both are hard coded to 'p.sort_order'. Check you files are the same. Also check for the same files under system/storage/modification.
I changed it to:Both are hard coded to 'p.sort_order'. Check you files are the same. Also check for the same files under system/storage/modification.
Code: Select all
$sort = 'pd.name';
What is the variable I should be using to force it to use 'Default', because that seems to work fine. If I select 'Default' from the dropdown menu, it sorts them alphabetically but doesn't come up with the error. The error occurs if I specifically choose 'Name (A-Z)' or 'Name (Z-A)'
Purchase it and get a refund if it doesn't fix?radact wrote: ↑Fri Feb 23, 2024 1:50 pmThere is also this extension which promises to fix the problem, looks more promising, but won't know until I purchase it:
https://www.opencart.com/index.php?rout ... rt%20order
Hoping there's another solution.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
https://github.com/opencart/opencart/bl ... #L240-L241
It looks like you have an theme, extension or modification that is changing the default OpenCart sorting.
Try using the default theme, disable extension/modifications one by one and compare your files against a clean download.
https://www.opencart.com/index.php?rout ... rt%20order
I am the developer of the extension. We dont promise to fix issues/bugs that may have created by another extension or hardcoded things. The extension works on a default OC installation and in most cases even on modified OpenCart installations but we cannot promise that will do the job and resolve a bug or so. The purpose of the extension is to define different sort order (than the default).
I suggest to fix any issue first and then purchase the extension if you want to change the sort order.
Easy Multi-Store Extension
ACS Courier Vouchers for OpenCart 2, 3 & 4
Skroutz Smart Cart (Έξυπνο καλάθι) for OpenCart
Έλεγχος Εγκυρότητας Ελληνικού ΑΦΜ για OpenCart
Change the style of your OpenCart admin dashboard for free!
We often allow customers to try our extensions and get a refund if there is a conflict.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
View all extensions | Request custom work | Pricing | Contact Me
Of course and in most cases we resolve the conflicts. But in this case it was asked if the extension will fix a problem/bug in the installation.paulfeakins wrote: ↑Tue Feb 27, 2024 7:03 pmWe often allow customers to try our extensions and get a refund if there is a conflict.
In this case, my advice is that any bug in the current installation should be fixed (not with an extension) anyway before trying to modify the default behaviour using any extension.
Easy Multi-Store Extension
ACS Courier Vouchers for OpenCart 2, 3 & 4
Skroutz Smart Cart (Έξυπνο καλάθι) for OpenCart
Έλεγχος Εγκυρότητας Ελληνικού ΑΦΜ για OpenCart
Change the style of your OpenCart admin dashboard for free!
However the error still remains when selecting Name A-Z or Name Z-A. All the other options such as Rating, Price etc all seem to work fine.
Code: Select all
Fatal error: Uncaught Exception: 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 'ORDER BY LCASE(pd.name) DESC, LCASE(pd.name) DESC LIMIT 0,20' at line 1<br />Error No: 1064<br />SELECT p.product_id, (SELECT AVG(rating) AS total FROM oc_review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM oc_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM oc_product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special FROM in /home/anoth305/public_html/shop/system/library/db/mysqli.php on line 40
It's not a deal breaker, because technically, "Default" is "NAME A-Z", so it operates correctly. The error message only occurs when you actually select "NAME A-Z" from the dropdown menu. Now I am stumped again.
I tried your suggestion, no change. Here is my modified mysqli.php file:ADD Creative wrote: ↑Fri Feb 23, 2024 8:01 amCould be you have something modifying your SQL query. The error seems to have "LCASE(pd.name) ASC" twice. Although that just could be the way the error was formatted.
For MySQL 8 you may have to remove NO_ZERO_DATE from the sql_mode.
Try making it the same as this line.
https://github.com/opencart/opencart/bl ... li.php#L18
Code: Select all
<?php
namespace DB;
final class MySQLi {
private $connection;
public function __construct($hostname, $username, $password, $database, $port = '3306') {
$this->connection = new \mysqli($hostname, $username, $password, $database, $port);
if ($this->connection->connect_error) {
throw new \Exception('Error: ' . $this->connection->error . '<br />Error No: ' . $this->connection->errno);
}
$this->connection->set_charset("utf8");
$this->connection->query("SET SQL_MODE = 'NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION'") ;
}
public function query($sql) {
$query = $this->connection->query($sql);
if (!$this->connection->errno) {
if ($query instanceof \mysqli_result) {
$data = array();
while ($row = $query->fetch_assoc()) {
$data[] = $row;
}
$result = new \stdClass();
$result->num_rows = $query->num_rows;
$result->row = isset($data[0]) ? $data[0] : array();
$result->rows = $data;
$query->close();
return $result;
} else {
return true;
}
} else {
throw new \Exception('Error: ' . $this->connection->error . '<br />Error No: ' . $this->connection->errno . '<br />' . $sql);
}
}
public function escape($value) {
return $this->connection->real_escape_string($value);
}
public function countAffected() {
return $this->connection->affected_rows;
}
public function getLastId() {
return $this->connection->insert_id;
}
public function connected() {
return $this->connection->ping();
}
public function __destruct() {
$this->connection->close();
}
}
Compare these two files against a clean version of that file from a clean download or from the following link.
https://github.com/opencart/opencart/bl ... roduct.php
Well that was bizarre! I looked in that folder and this is what I found:ADD Creative wrote: ↑Wed Feb 28, 2024 5:36 pmFind your catalog/model/catalog/product.php file. Also look for a system/storage/modification/catalog/model/catalog/product.php file.
Compare these two files against a clean version of that file from a clean download or from the following link.
https://github.com/opencart/opencart/bl ... roduct.php

Looks like this other product.php file was created nearly 4 years ago, by what, I have no idea. So switched it around to the .old file, which looks to be intact, and it seems to have now fixed the problem! NAME A-Z and NAME Z-A works again!
Maybe the problem has been there for a long time and I never noticed it before. I'm glad it's back to 100% again. So far I haven't noticed any other functionality issues as a result of reverting back to the original.
Thank you so much for everyone for pointing me in the right direction. :-)
Users browsing this forum: No registered users and 13 guests