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 (101439,101439,101588,101632,101641,101667,101735,101757,101782,101816,101885,101919,101922,101931,101934,101947,101984,102034,102080,102099,102128,102133,102183,102229,102288,102505,102621,102653,102827,102833,102892,102991,103019,103074,103082,103210,103221,103311,103317,103436,103474,103482,103702,103727,103742,103767,103792,103798,103917,104026,104070,104138,104187,104193,104212,104227,104277,104402,104555,104605,104606,104623,104660,104669,104675,104685,104694,104759,104884,105062,105087,105088,105105,105155,105161,105325,105439,105547,105572,105573,105584,105638,105644,105830,105885,106124,106130,106279,106316,106325,106340,106371,106421,106507,106568,106708,106745,106751,106772,106836,106907,107047,107084,107090,107111,107175,107217,107244,107258,107422,107428,107449,107513,107521,107598,107725,107762,107789,107859,107936,108063,108100,108127,108199,108235,108402,108439,108466,108537,108714,108741,108778,108805,108876,108926,108958,109028,109111,109144,110515,110579,110588,110590,110591,110784,110785,110786,110787,110788,110789,110790,110791,110792,110799,110818,110826,110837,110838,110839,110840,110841,110856,110887,110908,110913,110952,110953,110965,111138,111294,111295,111456,111457,111458,111459,111460,111468,111496,111497,111498,111514,111515,111516,111517,111519,111520,111521,111522,111523,111542,111543,111544,111545,111558,111559,111607,111627,111628,111629,111630,111631,111654,111663,111689,111690,111691,111692,111693,111694,111695,111696,111697,111698,111699,111700,111770,111771,111772,111800,111803,111804,111805,111851,111854,111855,111856,111857,111863,111864,111866,111939,112041,112042,112049,112050,112051,112052,112076,112077,112078,112079,112080,112088,112132,112140,112189,112232,112233,112245,112339,112375,112376,112459,112460,112461,112504,112526,112533,112534,112535,112557,112558,112568,112569,112570,112573,112574,112575,112576,112577,112581,112582,112583,112584,112585,112586,112587,112588,112589,112590,112591,112592,112593,112594,112595,112596,112597,112598,112599,112600,112601,112602,112603,112604,112605,112606,112607,112608,112609,112610,112611,112629,112659,112728,112762,112830,112852)
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 17600,100; |
|