I recently upgraded from 1.5.7 to 1.5.8 and started receiving the following error whenever a search is done in SBA Search. I went back to 1.5.7 and it did not have the error. Then I tried upgrading for the second time with new douwn loads etc. and the error repeated. It appears the error is in 1.5.8.
Has anyone else experienced the error?
SBA Error
Product ID Search
[21-Jul-2023 21:20:31 UTC] Request URI: /shop_new/flinG-zvG-sKips/index.php?cmd=products_with_attributes_stock&page=1&search_order_by=products_id, IP address: 69.137.114.242, Language id 1
#1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:667]
#2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:634]
#3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:275]
#4 queryFactory->Execute() called at [/flinG-zvG-sKips/includes/classes/split_page_results.php:220]
#5 splitPageResults->numberRows() called at [/flinG-zvG-sKips/includes/classes/split_page_results.php:131]
#6 splitPageResults->__construct() called at [/flinG-zvG-sKips/includes/classes/products_with_attributes_stock.php:389]
#7 products_with_attributes_stock->displayFilteredRows() called at [/flinG-zvG-sKips/products_with_attributes_stock.php:1506]
#8 require(/flinG-zvG-sKips/products_with_attributes_stock.php) called at [/flinG-zvG-sKips/index.php:11]
--> PHP Fatal error: 1060uplicate column name 'products_id' :: SELECT count(*) as total FROM (SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_id FROM products_attributes pa INNER JOIN products_description pd ON (pa.products_id = pd.products_id) INNER JOIN products p ON (pa.products_id = p.products_id) WHERE pd.language_id=1 ORDER BY p.products_id ) countresults ==> (as called by) /flinG-zvG-sKips/includes/classes/split_page_results.php on line 220 <== in /includes/classes/db/mysql/query_factory.php on line 667.
There's a combination of reasons for the error now occurring in Zen cart 1.5.8, but not before. I thought I had sufficiently addressed such issues, but looking at the code and the message log posted, I clearly see that I had not.
I'm not yet sure I consider this the most efficient or best solution, but it works to address the problem.
In admin/includes/classes/products_with_attributes_stock.php at line 366, change it from:
To:Code:if ($fieldsKey !== false) {
The issue ultimately is in the situation that occurred, the products_id was used as a search option, as well the products_attributes table's products_id is used as a returned value. In the loop of the above code, the expectation was to remove one of them from the query, but the existing logic doesn't support that.Code:if ($fieldsKey !== false || 'products_id' === substr($fieldsKey, strpos($fieldsKey, '.') + 1)) {
Part of a goal solution is to revisit why the product_attributes table products_id is used so that may be able to eliminate that as a problem. It's been so long since this section of code was developed I don't yet recall why that specifically is used and I haven't looked at it as part of this solution. Just wanted to fix the observed problem at least temporarily.
Thank you for reporting this issue.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Still have the same problem.
When entering the Product_ID in the search box.
WARNING: An Error occurred, please let us know! If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you entered valid data.
Then an error log is created.
[24-Jul-2023 12:17:13 UTC] Request URI: /shop_new/XlinG-zvZ-sBips/index.php?cmd=products_with_attributes_stock&page=1&search_order_by=products_id, IP address: 174.212.102.144, Language id 1
#1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:667]
#2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:634]
#3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:275]
#4 queryFactory->Execute() called at [/deleted/includes/classes/split_page_results.php:220]
#5 splitPageResults->numberRows() called at [/Deleted/includes/classes/split_page_results.php:131]
#6 splitPageResults->__construct() called at [/XlinG-zvZ-sBips/includes/classes/products_with_attributes_stock.php:389]
#7 products_with_attributes_stock->displayFilteredRows() called at [/Deleted/products_with_attributes_stock.php:1532]
#8 require(/XlinG-zvZ-sBips/products_with_attributes_stock.php) called at [/Deleted/index.php:11]
--> PHP Fatal error: 1060uplicate column name 'products_id' :: SELECT count(*) as total FROM (SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_id FROM products_attributes pa INNER JOIN products_description pd ON (pa.products_id = pd.products_id) INNER JOIN products p ON (pa.products_id = p.products_id) WHERE pd.language_id=1 ORDER BY p.products_id ) countresults ==> (as called by) /XlinG-zvZ-sBips/includes/classes/split_page_results.php on line 220 <== in /includes/classes/db/mysql/query_factory.php on line 667.
rather than doing it this way, could one not simply change line 352 to p.products_id? i think it would be simpler. ie:
i think that should work.Code://from $retFields = array( 'pa.products_id', 'pd.products_name', 'p.products_quantity', 'p.products_model', 'p.products_image', 'p.products_type', 'p.master_categories_id', ); //to $retFields = array( 'p.products_id', 'pd.products_name', 'p.products_quantity', 'p.products_model', 'p.products_image', 'p.products_type', 'p.master_categories_id', );
Of course, it is/was one of many potential solutions to the reported issue.
Even still, there's an unresolved issue that was identified by this reporting. But, if happy with the results then will seek to resolve at a later date to further address what is desired in this area of code. I know I don't like the current results, but I can still get what I need.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Current version 1.5.7b
Using 1 option name with "SBA Select List (Dropdown) Basic" and I would like to rearrange how the quantity and price show in the dropdown. Current order is option value + stock qty + price. Would like to have it read option value + price + stock qty.
Pretty sure I need to edit class.products_with_attributes_stock.php not sure where. Any guidance would be appreciated.
Thanks
Last question, then I have a lot of other work to do.
How do I set "No, Do not show Quantity Box" in EP?
Bookmarks