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 (6,424,523,552,645,646,707,761,796,818,859,862,891,1120,1136,1163,1249,1259,1346,6001,6002,60001,60002,60003,60004,60005,60006,60007,60008,60009,60010,60011,60012,60013,60014,60015,60016,60017,60018,60019,60020,60021,60022,60023,60024,60025,60026,60027,60028,60029,60030,60031,60032,60033,60034,60035,60036,60037,60038,60039,60040,60041,60042,60043,60044,60045,60046,60047,60048,60049,60050,60051,60052,60053,60054,60055,60056,60057,60058,60059,60060,60061,60062,60063,60064,60065,60066,60067,60068,60069,60070,60071,60072,60073,60074,60075,60076,60077,60078,60079,60080,60081,60082,60083,60084,60085,60086,60087,60088,60089,60090,60091,60092,60093,60094,60095,60096,60097,60098,60099,60100,60101,60102,60103,60104,60105,60106,60107,60108,60109,60110,60111,60112,60113,60114,60115,60116,60117,60118,60119,60120,60121,60122,60123,60124,60125,60126,60127,60128,60129,60130,60131,60132,60133,60134,60135,60136,60137,60138,60139,60140,60141,60142,60143,60144,60145,60146,60147,60148,60149,60150,60151,60152,60153,60154,60155,60156,60157,60158,60159,60160,60161,60162,60163,60164,60165,60166,600001,600002,600003,600004,600005,600006,600007,600008,600009,600010,600011,600012,600013,600014,600015,600016,600017,600018,600019,600020,600021,600022,600023,600024,600025,600026,600027,600028,600029,600030,600031,600032,600033,600034,600035,600036,600037,600038,600039,600040,600041,600042,600043,600044,600045,600046,600047,600048,600049,600050,600051,600052,600053,600054,600055,600056,600057,600058,600059,600060,600061,600062,600063,600064,600065,600066,600067,600068,600069,600070,600071,600072,600073,600074,600075,600076,600078,600079,600080,600081,600082,600083,600084,600085,600086,600087,600088,600089,600090,600091,600092,600093,600094,600095,600096,600097,600098,600099,600100,600101,600102,600103,600104,600105,600106,600107,600108,600109,600110,600111,600112,600113,600114,600115,600116,600117,600118,600119,600120,600121,600122,600123,600124,600125,600126,600127,600128,600129,600130,600131,600132,600133,600134,600135,600136,600137,600138,600139,600140,600141,600142,600143,600144,600145,600146,600147,600148,600149,600150,600151,600152,600153,600154,600155,600156,600157,600158,600159,600160,600161,600162,600163,600164,600165,600166,600167,600168,600169,600170,600171,600172,600173,600174,600175,600176,600177,600178,600179,600180,600181,600182,600183,600184,600185,600186,600187,600188,600189,600190,600191,600192,600193,600194,600195,600196,600197,600198,600199,600200,600201,600202,600203,600204,600205,600206,600207,600208,600209,600210,600211,600212,600213,600214,600215,600216,600217,600218,600219,600220,600221,600222,600223,600224,600225,600226,600227,600228,600229,600230,600231,600232,600233,600234,600235,600236,600237,600238,600239,600240,600241,600242,600243,600244,600245,600246,600247,600248,600249,600250,600251,600252,600253,600254,600255,600256,600257,600258,600259,600260,600261,600262,600263,600264,600265,600266,600267,600268,600269,600270,600271,600272,600273,600274,600275,600276,600277,600278,600279,600280,600281,600282,600283,600284,600285,600286,600287,600288,600289,600290,600291,600292,600293,600294,600295,600296,600297,600298,600299,600300,600301,600302,600303,600304,600305,600306,600307,600308,600309,600310,600311,600312,600313,600314,600315,600316,600317,600318,600319,600320,600321,600322,600323,600324,600325,600326,600327,600328,600329,600330,600331,600332,600333,600334,600335,600336,600337,600338,600339,600340,600341,600342,600343,600344,600345,600346,600347,600348,600349,600350,600351,600352,600353,600354,600355,600356,600357,600358,600359,600360,600361,600362,600363,600364,600365,600366,600367,600368,600369,600370,600371,600372,600373,600374,600375,600376,600377,600378,600379,600380,600381,600382,600383,600384,600385,600386,600387,600388)
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 14300,100; |
|