SELECT SQL_CALC_FOUND_ROWS p.* , (SELECT SUM(items_sold) FROM SC_products psort, SC_modifications_items misort WHERE psort.productID=misort.productID AND misort.Owner=p.productID) as items_sold, name_ru AS _name_sort, (SELECT MAX(in_stock) FROM SC_products p1, SC_modifications_items mi1 WHERE p1.productID=mi1.productID AND mi1.Owner=p.productID)>0 as `is_in_stock` FROM SC_products p WHERE ( (p.productID IN (26425,26426,26427,26428,26429,26430,26431,26432,26433,26434,26437,26438,26439,26440,26441,26442,26443,26452,26454,26455,26465,26467,26469,26470,26473,26475,26478,26481,26605,26610,26611,26613,26614,26615,26618,26619,26790,26791,26794,26796,26799,26800,26806,26810,26811,26838,26839,26841,27068,27071,27110,27113,27117,27118,27121,27123,27124,27125,27131,27133,27136,27137,27138,27227,27228,27230,27232,27234,27235,27248,27251,27253,27257,27258,27259,27370,27371,27388,27389,27391,27392,27394,27396,27653,27654,27655,27664,27666,27667,27668,27670,27671,27862,27863,27867,27868,27869,27870,27871,27872,27873,27874,27875,27876,27877,27878,27942,27943,27944,27954,27956,27958,27960,27961,27962,27963,28872,29304,29305,29306,29315,29498,29700,29702,29703,29704,29705,30281,30283,30286,30288,30290,30588,30668,30690,30691,31327,31328,31333,31335,31337,31344,31347,31348,31349,31351,31352,31353,31354,31356,31358,31362,31370,31497,31699,31702,31705,31708,31713,31714,31715,31719,31722,31724,31726,31729,31732,31959,31960,31962,31964,31967,31968,31970,31972,32267,32271,32338,32437,32438,32493,32496,32497,32499,32501,32504,32508,32596,32599,32667,32668,32671,32672,32675,32676,32708,32709,32787,32789,32791,32792,32794,32798,32803,32806,32857,32897,32970,32971,32972,32973,32975,32976,32981,32985,33020,33022,33023,33026,33032,33034,33035,33047,33050,33051,33180,33181,33182,33183,33184,33185,33214,33215,33216,33227,33229,33230,33239,33249,33250,33251,33252,33253,33254,33255,33257,33258,33259,33264,33267,33269,33625,33626,33627,33628,33629,33634,33635,33636,33638,33669,33670,33671,33672,33673,33783,33784,33893,34099,34659,34715,34716,34717,34761,34762,34881,34883,34885,34887,34888,34889,34890,34891,34892,34893,34894,34895,34896,34897,34938,34939,35718,35758,35759,35855,35935,35936,35937,35962,35979,35980,35981,36004,36437,36438,36439,36513,36514,36515,36516,36517,36518,36519,36520,36521,36522,36523,36530,36540,36779,36784,36786,36787,36836,36844,36847,38773,38852,39944,39982,39983,39984,39985,39986,40022,40174,40175,40176,40177,40179,40182,40189,40190,40194,40367,40368,40369,40370,40371,40373,40374,40375,40376,40377,40379,40380,40396,40398,40401,40402,40404,40405,40406,40407,40408,40414,41011,41012,41013,41014,41022,41485,41581,41584,41587,41589,41590,41595,41597,41689,42016,42017,42019,42344,42356,42395,42396,42454,42455,42500,42632,42989,42992,43002,43003,43011,43119,43120,43121,43122,43207,43312,43316,43365,43368,43370,43372,43374,43376,43378,43381,43383,43386,43388,43390,43392,43394,43398,43470,43472,43479,43482,43509,43516,43563,43597,43800,44041,44045,44048,44072,44381,44384,44387,45235,45452,45517,45519,45589,45592,45595,45598,45600,45603,45606,45609,45613,45873,45876,45990,46143,46929,46948,47086,47102,47234,47237,47240,47244,47247,47250,47417,47900,48123,48127,48131,48135,48139,48143,48147,48211,48216,48218,48471,48478,48485,48600,48651,48653,48734,48736,48738,48740,48742,48747,48750,49072,49486,49489,49492,49495,49498,49501,49504,49517,49548,49556,49558,49560,49562,49564,49569,49580,49831,49841,49847,49868,49992,50076,50183,50187,50465,50469,50471,50474,50476,50478,50708,50710,50712,50714,50716,50719,50721,50723,50725,50727,50730,50733,50735,51066,51267,51296,51298,51674,51680,51683,51690,51695,51698,51701,51703,51941,51943,51945,51947,52287,52291,52368,52935,52961,53276,53532,54646,54659,54714,54818,54825,54854,54917,54924,54945,70449)) OR (categoryID IN (15518)) ) AND ( enabled=1) ORDER BY `is_in_stock` DESC, items_sold DESC LIMIT 360,40