Notice: 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 por.price ASC LIMIT 1) as oprice, (SELECT AVG(rating) AS total FROM o' at line 1
Error No: 1064
SELECT DISTINCT SQL_CALC_FOUND_ROWS * FROM (SELECT p.product_id, (SELECT SUM(rate) FROM oc_tax_rule tr1 LEFT JOIN oc_tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN oc_tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN oc_zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN oc_geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = p.tax_class_id AND tr2.type = 'F' AND ((tr1.based = 'store' AND z2gz.country_id = '220' AND z2gz.zone_id IN ('0', '0'))) AND tr2cg.customer_group_id = '1') AS fixed_tax,(SELECT SUM(rate) FROM oc_tax_rule tr1 LEFT JOIN oc_tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN oc_tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN oc_zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN oc_geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = p.tax_class_id AND tr2.type = 'P' AND ((tr1.based = 'store' AND z2gz.country_id = '220' AND z2gz.zone_id IN ('0', '0'))) AND tr2cg.customer_group_id = '1') AS percent_tax, p.price, (SELECT por.price as oprice FROM oc_product_option_relation por LEFT JOIN oc_product_option_value pov ON pov.product_id = por.product_id AND pov.product_option_value_id = por.var WHERE por.product_id = p.product_id AND pov.option_value_id IN() ORDER BY por.price ASC LIMIT 1) as oprice, (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 < '2018-12-17 09:57:00') AND (pd2.date_end = '0000-00-00' OR pd2.date_end > '2018-12-17 09:57:00')) 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 < '2018-12-17 09:57:00') AND (ps.date_end = '0000-00-00' OR ps.date_end > '2018-12-17 09:57:00')) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special FROM oc_product_to_category p2c LEFT JOIN oc_product p ON (p2c.product_id = p.product_id) LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) INNER JOIN oc_product_attribute AS pa431 ON ( p.product_id = pa431.product_id ) WHERE pa431.attribute_id = '431' AND (pa431.text = 'В наличии') AND pd.language_id = '1' AND p.status = '1' AND p.date_available <= '2018-12-17 09:57:00' AND p2s.store_id = '0' AND p2c.category_id = '4622920' GROUP BY p.product_id ORDER BY (CASE WHEN special IS NOT NULL THEN special WHEN discount IS NOT NULL THEN discount WHEN oprice IS NOT NULL THEN oprice ELSE p.price END) ASC, LCASE(pd.name) ASC) AS tt LIMIT 0,20 in /home/viluta/vilutashop.com/www/system/database/mysql.php on line 50