PHP Fatal error: 1060:Duplicate column name 'products_id'
[Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here.
And, remove this comment before actually posting!]
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: 1060:Duplicate 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.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
That's a fatal error in the "Stock by Attributes" add-on, not the Zen Cart core.
I'm pretty sure that the current support thread for that add-on is here: https://www.zen-cart.com/showthread....r-v1-3-5-1-3-9
That's where you should report the issue.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
If you look at admin/includes/classes/products_with_attributes_stock.php line 389, you're going to see that it calls numberRows() with a string that looks like this:
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
Just remove the last part (, p.products_id) so it looks like this:
SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
I did not see a line that you are secribing. Here is line 389 and the line before and after.
if (!isset($_GET['seachPID']) && !isset($_GET['pwas-search-button']) && !isset($_GET['updateReturnedPID'])) {
$products_split = new splitPageResults($_GET['page'], STOCK_SET_SBA_NUMRECORDS, $query_products, $products_query_numrows);
}
I do not see a line like you are describing.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
Search backwards for the definition of $query_products.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
Quote:
Originally Posted by
swguy
Search backwards for the definition of $query_products.
I tried looking backwards for the line you are describing and did not find a line with the product id defined twice. I also checked all the select distinct and did not find two definitions for the product id in the same statement.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
Quote:
Originally Posted by
jodean
#7 products_with_attributes_stock->displayFilteredRows() called at [/flinG-zvG-sKips/products_with_attributes_stock.php:1506]
i believe this is where your problem lies... not in the classes file.
best.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
I am sorry Carl but I do not understand your reply.
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
This issue ended up being brought up in stock by attributes where a solution has been provided: https://www.zen-cart.com/showthread....34#post1396034
There are some inherent differences between being able to operate under Zen cart 1.5.7 and 1.5.8 and there have been some changes to Zen cart 1.5.8 requiring other code to be changed, but that's a separate and unrelated topic. While I stated I didn't fully like my provided solution, I have determined a more generic fix that still needs to be uploaded. Of course it would help to hear back that the proposed solution at least worked. It was posted within 3 hours of reporting the here which took 2 hours to post on the appropriate forum thread.
So hey, @jodean, what's the status?
Re: PHP Fatal error: 1060:Duplicate column name 'products_id'
Closing this thread; please continue on SBA thread as noted by @mc12345678.