SELECT g.`id`, g.`name`, g.`fullname`, g.`slug`, p.`price`, g.`at_stock`, g.`on_hand`, g.`min_sale`, g.`mainPhotoID`, i.`path` AS imagePath, s.`name` AS supName, s.`abbr` AS supAbbr
FROM `goods` g
LEFT JOIN `prices` AS p ON (p.`good_id`=g.`id` AND p.`type`=g.`price_type`)
LEFT JOIN `category` AS c ON c.`id`=g.`category_id`
LEFT JOIN `brands` AS b ON b.`id`=g.`brand_id`
LEFT JOIN `suppliers` AS s ON s.`id`=g.`supplier_id`
LEFT JOIN `images2` AS i ON (i.`id`=g.`mainPhotoID` AND i.`hide`='no')
LEFT JOIN a_prod_catalog_goods as pg ON pg.good_id=g.id
LEFT JOIN `a_prod_filter_good_vs` AS gp ON (g.id = gp.good_id)
WHERE pg.`category_id` IN (700570,700570,700571,701721,701722,701723,701724,701725,701726,701727,701728,701729,701730,701731,701732,701733,701734,701735,701736,701737,701738,701739,701740,701741,701742,701743,701744,701745,701746,701747,701748,701749,701750,701751,701752,701753,701754,701755,701756,701757,701758,701759,701760,701761,701762,701763,701764,701765,701766,701767,701768,701769,701770,701771,701772,701773,701774,701775,701776,701777,701778,701779,701780,701781,701782,701783,701784,701785,701786,701787,701788,701789,701790,701791,701792,701793,701794,701795,701796,701797,701798,701799,701800,701801,701802,701803,701804,701805,701806,701807,701808,701809,701810,701811,701812,701813,701814,701815,701816,701817,701818,701819,701820,701821,701822,701823,701824,701825,701826,701827,701828,701829,701830,701831,701832,702276,702309,702310,702343,702465,702479)
AND p.`price`!=0
GROUP BY g.id
ORDER BY IF(g.`at_stock`='yes','0',IF(g.`at_stock`='order','1',IF(g.`on_hand`>0,'0','2'))), g.`fullname` LIMIT 33200,100; |
|