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 (101427,101427,101626,101886,101989,102122,102265,102496,102772,102839,103105,103184,103187,103323,103424,103454,103637,103656,103670,103692,103737,103750,103919,103936,104119,104152,104164,104173,104494,104560,104567,104634,104646,104823,104824,104947,105049,105079,105132,105146,105218,105225,105281,105292,105363,105412,105432,105522,105615,105629,105684,105777,105859,105914,106082,106140,106203,106263,106321,106402,106442,106465,106570,106637,106651,106657,106714,106720,106784,106909,106933,106947,106976,106996,107053,107120,107151,107270,107284,107333,107368,107391,107447,107489,107560,107588,107624,107673,107822,107829,107962,108046,108143,108160,108166,108314,108383,108470,108482,108505,108653,108692,108745,108753,108821,108887,108928,109074,109256,109368,109458,109479,109569,109590,109701,109990,110071,110086,110629,110745,110746,110768,111007,111067,111759,112331,112354,112822)
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 49000,100; |
|