Hi all. I have an issue with the SBA add-on after upgrade to MySQL 5.7.24.
PHP Fatal error: 1140:
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'freedomh_zencart.pwas.quantity'; this is incompatible with sql_mode=only_full_group_by :: select distinct pwas.quantity as quantity, count(distinct pwasans.attribute_type) as pwasans_quantity from products_with_attributes_stock pwas, products_with_attributes_stock_attributes_non_stock pwasans
This SELECT is in file /public_html/includes/classes/pad_sba_sequenced_dropdowns.php. It is quite a complicated looking SQL statement (for me anyway) with a number of OR statements. I'm assuming I need to add a GROUP BY statement in this SQL Statement, but not sure where. The other option would be to update SQL_MODE and remove the ONLY_FULL_GROUP_BY setting, but doesn't look like the correct thing to do here.
Any ideas how to correct or make this SELECT statement work with MySQL 5.7.24?
I'm running Zen Cart 1.5.5f, Database Patch Level: 1.5.5. Everything else seems find except when you hit the product Detail Screen and it hits this code.
Thanks for any pointers.
Chris
SQL as follows:
From file /public_html/includes/classes/pad_sba_sequenced_dropdowns.php
PHP Code:
$attribute_stock_query = "select distinct pwas.quantity as quantity, count(distinct pwasans.attribute_type) as pwasans_quantity from " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas, " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK_ATTRIBUTES_NON_STOCK . " pwasans
where pwasans.attribute_type = :products_options:
and pwasans.attribute_type_source_id = :products_id:
AND pwasans.attribute_type_id = (
SELECT pa.options_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_id = :products_id:
AND pa.options_values_id = :options_values_id:)
OR (
pwasans.attribute_type = :products_values:
AND pwasans.attribute_type_source_id = :products_id:
AND pwasans.attribute_type_id = :options_values_id:
" . /*(SELECT pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_attributes_id = :check_attribute_id:) */ "
)
OR (
pwasans.attribute_type = :values:
AND pwasans.attribute_type_source_id = 0
AND pwasans.attribute_type_id = :options_values_id:
AND pwasans.attribute_type_id = (SELECT pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_id = :products_id:
AND pa.options_values_id = :options_values_id:)
" . /*(SELECT pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_attributes_id = :check_attribute_id:) */ "
)
OR (
pwasans.attribute_type = :options:
AND pwasans.attribute_type_source_id = 0
AND pwasans.attribute_type_id = :options_values_id:
AND pwasans.attribute_type_id = (SELECT pa.options_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_id = :products_id:
AND pa.options_values_id = :options_values_id:)
" . /*(SELECT pa.options_values_id FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_attributes_id = :check_attribute_id:) */ "
)
OR pwas.products_id = :products_id:
" . (STOCK_ALLOW_CHECKOUT !== 'false'
? ""
: "AND pwas.quantity > 0 ") . "
AND pwas.stock_attributes
like (SELECT products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . "
WHERE products_id = :products_id:
and options_values_id = :options_values_id:)
OR pwas.products_id = :products_id: AND pwas.stock_attributes
like CONCAT((SELECT products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . "
WHERE products_id = :products_id:
and options_values_id = :options_values_id:),',%')
" . (STOCK_ALLOW_CHECKOUT !== 'false'
? ""
: "AND pwas.quantity > 0 ") . "
or pwas.products_id = :products_id:
AND pwas.stock_attributes
like CONCAT('%,',(SELECT products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . "
WHERE products_id = :products_id:
and options_values_id = :options_values_id:),',%')
" . (STOCK_ALLOW_CHECKOUT !== 'false'
? ""
: "AND pwas.quantity > 0 ") . "
or pwas.products_id = :products_id:
AND pwas.stock_attributes
like CONCAT('%,',(SELECT products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . "
WHERE products_id = :products_id:
and options_values_id = :options_values_id:))
" . (STOCK_ALLOW_CHECKOUT !== 'false'
? ""
: "AND pwas.quantity > 0 ");
Bookmarks