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 (101447,101447,101664,101786,101935,102084,102162,102337,102842,102933,103236,103326,103417,103563,103688,103697,103807,103898,104182,104292,104383,104444,104664,104774,104865,104915,104926,105259,105350,105426,105835,106139,106230,106522,111063,111064,111066,111959,112717)
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 3800,100; |
|