string(2246) "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())) AND (ps.discount_period IS NULL OR ps.discount_period = '' OR FLOOR(FLOOR((UNIX_TIMESTAMP(NOW())-ps.save_time)/86400)/((CASE ps.discount_period WHEN '2_week' THEN 1 WHEN '3_week' THEN 2 WHEN '4_week' THEN 3 WHEN '5_week' THEN 4 WHEN '6_week' THEN 5 WHEN '7_week' THEN 6 WHEN '8_week' THEN 7 WHEN '9_week' THEN 8 WHEN '10_week' THEN 9 WHEN '11_week' THEN 10 ELSE 0 END)*7))%ps.discount_period=0) ) AND ( ((ps.discount_week IS NULL) OR (ps.discount_week = '') OR (ps.discount_week LIKE '[]') OR (ps.discount_week LIKE '%"Tuesday"%')) AND ((ps.discount_time IS NULL) OR (ps.discount_week = '') OR (ps.discount_time LIKE '[]') OR (ps.discount_time LIKE '%"time_l"%')) ) 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) LEFT JOIN oc_hpmrr_links hl ON (p.product_id = hl.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND p2c.category_id = '59' GROUP BY IF(hl.parent_id IS NOT NULL, hl.parent_id, p.product_id) ORDER BY (p.quantity > 0) DESC, p.date_added DESC, LCASE(pd.name) ASC"