Advertisement
MrViSiOn

Untitled

Oct 22nd, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 45.10 KB | None | 0 0
  1.         SELECT p.id_product FROM ps_product_lang p INNER JOIN ps_product p2 ON p.id_product = p2.id_product WHERE (LOWER(p.name) LIKE LOWER('%faro%') OR LOWER(p.description_short) LIKE LOWER('%faro%') OR LOWER(p.description) LIKE LOWER('%faro%')  ) AND p2.active = 1 AND p2.indexed = 1 AND p2.visibility IN ("both", "search")
  2.  
  3.  
  4.  
  5.     SELECT si.id_product
  6.                     FROM ps_search_word sw
  7.                     LEFT JOIN ps_search_index si ON sw.id_word = si.id_word INNER JOIN ps_product p2 ON si.id_product = p2.id_product
  8.                     WHERE sw.id_lang = 1
  9.                         AND sw.id_shop = 1
  10.                         AND LOWER(sw.word) LIKE LOWER(
  11.                     '%faro%')  AND p2.active = 1 AND p2.indexed = 1 AND p2.visibility IN ("both", "search")
  12.  
  13.  
  14.  
  15.  
  16.  
  17.     SELECT p.id_product FROM ps_product_lang p INNER JOIN ps_product p2 ON p.id_product = p2.id_product WHERE (LOWER(p.name) LIKE LOWER('%derecho%') OR LOWER(p.description_short) LIKE LOWER('%derecho%') OR LOWER(p.description) LIKE LOWER('%derecho%')  ) AND p2.active = 1 AND p2.indexed = 1 AND p2.visibility IN ("both", "search")
  18.  
  19.  
  20.  
  21.  
  22.  
  23.     SELECT si.id_product
  24.                     FROM ps_search_word sw
  25.                     LEFT JOIN ps_search_index si ON sw.id_word = si.id_word INNER JOIN ps_product p2 ON si.id_product = p2.id_product
  26.                     WHERE sw.id_lang = 1
  27.                         AND sw.id_shop = 1
  28.                         AND LOWER(sw.word) LIKE LOWER(
  29.                     '%derecho%')  AND p2.active = 1 AND p2.indexed = 1 AND p2.visibility IN ("both", "search")
  30.  
  31.  
  32.         SELECT COUNT(*) FROM ( SELECT * FROM ((SELECT
  33.             CONVERT(p.reference, UNSIGNED INT) AS reference, p.id_product, p.id_supplier, p.id_manufacturer, p.id_category_default, p.id_shop_default, p.id_tax_rules_group, p.on_sale, p.online_only, p.ean13,             p.upc, p.ecotax, p.minimal_quantity, p.price, p.wholesale_price, p.unity, p.unit_price_ratio, p.additional_shipping_cost, p.supplier_reference, p.location, p.width, p.height, p.depth, p.weight,
  34.             p.quantity_discount, p.customizable, p.uploadable_files, p.text_fields, p.active, p.redirect_type, p.id_product_redirected, p.available_for_order, p.available_date, p.condition,
  35.             p.show_price, p.indexed, p.visibility, p.cache_is_pack, p.cache_has_attachments, p.is_virtual, p.cache_default_attribute, p.date_add, p.date_upd, p.advanced_stock_management,
  36.             product_shop.id_shop
  37.             , stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity,
  38.                 pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
  39.              MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name ,(
  40.                 SELECT SUM(weight)
  41.                 FROM ps_search_word sw
  42.                 LEFT JOIN ps_search_index si ON sw.id_word = si.id_word
  43.                 WHERE sw.id_lang = 1
  44.                     AND sw.id_shop = 1
  45.                     AND si.id_product = p.id_product
  46.                     AND (sw.word LIKE 'faro%' OR sw.word LIKE 'derecho%')
  47.             ) POSITION, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
  48.                 DATEDIFF(
  49.                     p.`date_add`,
  50.                     DATE_SUB(
  51.                         NOW(),
  52.                         INTERVAL 3 DAY
  53.                     )
  54.                 ) > 0 NEW,
  55.                 IFNULL(feat2.VALUE, 0) AS reffab,
  56.                 IFNULL(feat4.VALUE, 0) AS refmarca
  57.                 FROM ps_product p
  58.                  INNER JOIN ps_product_shop product_shop
  59.         ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
  60.  
  61.                 INNER JOIN `ps_product_lang` pl ON (
  62.                     p.`id_product` = pl.`id_product`
  63.                     AND pl.`id_lang` = 1 AND pl.id_shop = 1
  64.                 )
  65.                 LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product`)
  66.                  LEFT JOIN ps_product_attribute_shop product_attribute_shop
  67.         ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1 AND product_attribute_shop.`default_on` = 1)
  68.                  LEFT
  69.             JOIN ps_stock_available stock
  70.             ON (stock.id_product = p.id_product AND stock.id_product_attribute = IFNULL(`product_attribute_shop`.id_product_attribute, 0) AND stock.id_shop = 1  )
  71.                 LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
  72.                 LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product`) LEFT JOIN ps_image_shop image_shop
  73.         ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)
  74.                 LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1)
  75.                 LEFT JOIN `ps_feature_product` feat1 ON (feat1.id_feature = 9 AND feat1.id_product = p.`id_product`)
  76.                 LEFT JOIN `ps_feature_value_lang` feat2 ON (feat1.id_feature_value = feat2.id_feature_value AND feat2.`id_lang` = 1)
  77.                 LEFT JOIN `ps_feature_product` feat3 ON (feat3.id_feature = 15 AND feat3.id_product = p.`id_product`)
  78.                 LEFT JOIN `ps_feature_value_lang` feat4 ON (feat3.id_feature_value = feat4.id_feature_value AND feat4.`id_lang` = 1)
  79.                 WHERE p.`id_product`  IN (247,690,724,851,858,865,1020,1097,1151,1152,1235,1414,1569,1575,1598,1673,1873,2087,2279,2280,2281,2283,2302,2458,2476,2663,2686,2824,2843,2923,3031,3113,3163,3236,3254,3454,3501,3770,3986,4147,4177,4203,4206,4207,4208,4210,4216,4217,4218,4225,4228,4229,4230,4232,4233,4235,4252,4254,4259,4263,4266,4267,4268,4269,4270,4274,4283,4284,4285,4287,4288,4289,4415,4644,5378,5409,5737,5760,5782,5856,5999,6396,6486,6541,6686,6687,6763,6786,6815,7022,7083,7084,7189,7199,7215,7270,7273,7275,7276,7278,7280,7292,7293,7294,7301,7303,7306,7307,7322,7324,7325,7331,7334,7337,7340,7341,7344,7346,7348,7420,7603,7609,7797,8027,8410,8562,8834,8958,9460,9526,9825,9834,10546,10776,11308,11370,11413,11491,11685,11899,12319,12335,12351,12352,12513,12553,12604,12647,12804,12824,13364,13568,13592,13621,13720,13754,13774,13806,13819,13836,13875,13893,14081,14152,14186,14230,14278,14290,14298,14317,14488,14570,14638,14639,14650,14663,14807,14829,14901,15205,15552,15587,15589,15781,15792,15923,15938,15994,16069,16097,16154,16234,16495,16559,16672,16700,16743,16771,16955,17029,17153,17689,17753,17824,18080,18150,18163,18208,18288,18352,18390,18485,18506,18532,18586,18686,18709,18726,18767,18859,18871,19058,19078,19080,19104,19220,19274,19276,19354,19379,19493,19530,19539,19770,19818,19891,19897,19993,20024,20297,20376,20398,20609,20702,20760,20791,20885,20890,20928,21039,21234,21311,21350,21404,21406,21524,21548,21592,21701,21804,21834,21841,21896,21988,22005,22007,22017,22033,22137,22204,22344,22375,22426,22449,22504,22630,22715,22867,22946,23045,23046,23078,23105,23311,23471,23543,23580,23623,23676,23721,23795,23881,23919,23929,24131,24138,24282,24315,24499,24531,24801,24843,24975,25014,25181,25195,25398,25422,25437,25649,25672,25700,25706,25746,25758,25797,25814,25913,26034,26231,26394,26409,26519,26620,26643,26677,26837,26956,27111,27113,27155,27222,27261,27298,27331,27372,27436,27460,27502,27516,27531,27552,27567,27623,27651,27685,27770,27817,27870,27912,27934,27978,28113,28139,28191,28515,28518,28521,28972,28973,28974,28979,28985,28986,28987,28989,28990,28991,28995,29001,29007,29008,29072,29225,29306,29479,29691,29991,30127,30214,30236,30558,30664,31175,31879,32039,32040,32049,32059,32145,32199,32352,32509,32513,32615,32628,32665,32765,32778,32779,32806,32817,32818,32852,32876,33432,33687,33954,34097,34215,34421,34425,34581,34637,34648,34741,35031,35173,35243,35246,35365,35618,35648,35802,35803,36023,36147,36423,36424,36514,36624,36856,36888,36903,36905,36911,37251,37354,37428,37473,37669,37916,38277,38287,38499,38724,38741,38870,38884,38896,39038,39183,39268,39430,39452,39767,39851,39893,40000,40002,40003,40020,40073,40247,40248,40370,40653,40716,40751,40938,41012,41013,41015,41051,41104,41196,41221,41282,41306,41309,41407,41431,41432,41433,41436,41437,41518,41520,41522,41669,41689,41690,41691,41721,41794,41796,41806,41807,41809,41862,41926,41927,41974,42017,42211,42220,42246,42315,42387,42392,42431,42508,42561,42665,42913,42968,43141,43315,43411,43412,43461,43576,43691,43755,43785,43868,44121,44129,44434,44436,44768,45008,45389,45831,46029,46129,46198,46590,46662,46774,46782,46867,47041,47042,47370,47481,47819,48118,48459,48467,48480,48535,48542,48590,48634,49256,49298,49313,49318,49324,49342,49362,49371,49380,49440,49467,49483,49566,49616,49639,49706,49765,49784,49841,49928,49946,50017,50110,50116,50124,50148,50164,50223,50249,50269,50282,50346,50366,50389,50394,50411,50425,50434,50586,50638,50651,51267,51319,51327,51336,51340,51440,51453,51498,51538,51644,51658,51739,51767,51796,51804,51943,52005,52634,52648,52722,52729,52822,53008,53229,53374,53418,53568,53587,53618,53677,53715,53727,53751,53811,53909,53924,53936,53943,53948,53952,53965,53976,53983,53994,53996,54076,54198,54274,54381,54416,54495,54517,54604,54674,54750,54794,55010,55130,55157,55216,55231,55236,55269,55374,55406,55410,55588,55629,55640,55667,55672,55678,55683,55737,55793,55819,55945,55960,56049,56055,56065,56113,56134,56176,56258,56277,56287,56335,56423,56424,56583,56799,56844,56862,56884,56885,56902,56903,56914,57020,57031,57124,57179,57274,57323,57391,57427,57432,57531,57617,57678,57772,57838,57844,57847,57852,57855,57926,58189,58232,58372,58376,58405,58421,58449,58478,58600,58612,58619,58705,58711,58749,58795,58960,58969,58971,58993,59011,59017,59107,59118,59135,59188,59195,59202,59206,59350,59364,59389,59428,59475,59500,59511,59545,59548,59567,59628,59820,59821,59825,59826,59828,59830,59833,59834,59840,59869,59910,59986,60021,60107,60194,60219,60225,60249,60331,60373,60427,60476,60488,60491,60533,60549,60554,60593,60653,60655,60730,60746,60763,60842,60843,60852,60867,60874,60880,60954,60965,60986,61000,61072,61075,61086,61089,61100,61286,61341,61490,61499,61601,61612,61613,61643,61784,61794,61836,61849,61877,62111,62160,62203,62207,62227,62249,62263,62279,62286,62321,62354,62363,62365,62415,62417,62447,62466,62474,62501,62513,62517,62541,62546,62563,62693,62706,62768,62775,62836,62919,62934,62991,62995,63030,63050,63114,63172,63215,63258,63273,63279,63281,63342,63388,63431,63436,63589,63596,63619,63626,63633,63680,63699,63780,63811,63899,64009,64035,64047,64128,64153,64179,64203,64219,64278,64317,64412,64415,64533,64547,64575,64591,64754,64757,64812,64959,65064,65279,65333,65485,65487)   AND IFNULL(stock.quantity, 0) > 0  AND IFNULL(p.price, 0) > 0
  80.                 GROUP BY product_shop.id_product
  81.                 ORDER BY CONVERT(p.reference, UNSIGNED INT) DESC
  82.                 ) UNION (SELECT
  83.             CONVERT(p.reference, UNSIGNED INT) AS reference, p.id_product, p.id_supplier, p.id_manufacturer, p.id_category_default, p.id_shop_default, p.id_tax_rules_group, p.on_sale, p.online_only, p.ean13,             p.upc, p.ecotax, p.minimal_quantity, p.price, p.wholesale_price, p.unity, p.unit_price_ratio, p.additional_shipping_cost, p.supplier_reference, p.location, p.width, p.height, p.depth, p.weight,
  84.             p.quantity_discount, p.customizable, p.uploadable_files, p.text_fields, p.active, p.redirect_type, p.id_product_redirected, p.available_for_order, p.available_date, p.condition,
  85.             p.show_price, p.indexed, p.visibility, p.cache_is_pack, p.cache_has_attachments, p.is_virtual, p.cache_default_attribute, p.date_add, p.date_upd, p.advanced_stock_management,
  86.             product_shop.id_shop
  87.             , stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity,
  88.                 pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
  89.              MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name ,(
  90.                 SELECT SUM(weight)
  91.                 FROM ps_search_word sw
  92.                 LEFT JOIN ps_search_index si ON sw.id_word = si.id_word
  93.                 WHERE sw.id_lang = 1
  94.                     AND sw.id_shop = 1
  95.                     AND si.id_product = p.id_product
  96.                     AND (sw.word LIKE 'faro%' OR sw.word LIKE 'derecho%')
  97.             ) POSITION, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
  98.                 DATEDIFF(
  99.                     p.`date_add`,
  100.                     DATE_SUB(
  101.                         NOW(),
  102.                         INTERVAL 3 DAY
  103.                     )
  104.                 ) > 0 NEW,
  105.                 IFNULL(feat2.VALUE, 0) AS reffab,
  106.                 IFNULL(feat4.VALUE, 0) AS refmarca
  107.                 FROM ps_product p
  108.                  INNER JOIN ps_product_shop product_shop
  109.         ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
  110.  
  111.                 INNER JOIN `ps_product_lang` pl ON (
  112.                     p.`id_product` = pl.`id_product`
  113.                     AND pl.`id_lang` = 1 AND pl.id_shop = 1
  114.                 )
  115.                 LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product`)
  116.                  LEFT JOIN ps_product_attribute_shop product_attribute_shop
  117.         ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1 AND product_attribute_shop.`default_on` = 1)
  118.                  LEFT
  119.             JOIN ps_stock_available stock
  120.             ON (stock.id_product = p.id_product AND stock.id_product_attribute = IFNULL(`product_attribute_shop`.id_product_attribute, 0) AND stock.id_shop = 1  )
  121.                 LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
  122.                 LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product`) LEFT JOIN ps_image_shop image_shop
  123.         ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)
  124.                 LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1)
  125.                 LEFT JOIN `ps_feature_product` feat1 ON (feat1.id_feature = 9 AND feat1.id_product = p.`id_product`)
  126.                 LEFT JOIN `ps_feature_value_lang` feat2 ON (feat1.id_feature_value = feat2.id_feature_value AND feat2.`id_lang` = 1)
  127.                 LEFT JOIN `ps_feature_product` feat3 ON (feat3.id_feature = 15 AND feat3.id_product = p.`id_product`)
  128.                 LEFT JOIN `ps_feature_value_lang` feat4 ON (feat3.id_feature_value = feat4.id_feature_value AND feat4.`id_lang` = 1)
  129.                 WHERE p.`id_product`  IN (247,690,724,851,858,865,1020,1097,1151,1152,1235,1414,1569,1575,1598,1673,1873,2087,2279,2280,2281,2283,2302,2458,2476,2663,2686,2824,2843,2923,3031,3113,3163,3236,3254,3454,3501,3770,3986,4147,4177,4203,4206,4207,4208,4210,4216,4217,4218,4225,4228,4229,4230,4232,4233,4235,4252,4254,4259,4263,4266,4267,4268,4269,4270,4274,4283,4284,4285,4287,4288,4289,4415,4644,5378,5409,5737,5760,5782,5856,5999,6396,6486,6541,6686,6687,6763,6786,6815,7022,7083,7084,7189,7199,7215,7270,7273,7275,7276,7278,7280,7292,7293,7294,7301,7303,7306,7307,7322,7324,7325,7331,7334,7337,7340,7341,7344,7346,7348,7420,7603,7609,7797,8027,8410,8562,8834,8958,9460,9526,9825,9834,10546,10776,11308,11370,11413,11491,11685,11899,12319,12335,12351,12352,12513,12553,12604,12647,12804,12824,13364,13568,13592,13621,13720,13754,13774,13806,13819,13836,13875,13893,14081,14152,14186,14230,14278,14290,14298,14317,14488,14570,14638,14639,14650,14663,14807,14829,14901,15205,15552,15587,15589,15781,15792,15923,15938,15994,16069,16097,16154,16234,16495,16559,16672,16700,16743,16771,16955,17029,17153,17689,17753,17824,18080,18150,18163,18208,18288,18352,18390,18485,18506,18532,18586,18686,18709,18726,18767,18859,18871,19058,19078,19080,19104,19220,19274,19276,19354,19379,19493,19530,19539,19770,19818,19891,19897,19993,20024,20297,20376,20398,20609,20702,20760,20791,20885,20890,20928,21039,21234,21311,21350,21404,21406,21524,21548,21592,21701,21804,21834,21841,21896,21988,22005,22007,22017,22033,22137,22204,22344,22375,22426,22449,22504,22630,22715,22867,22946,23045,23046,23078,23105,23311,23471,23543,23580,23623,23676,23721,23795,23881,23919,23929,24131,24138,24282,24315,24499,24531,24801,24843,24975,25014,25181,25195,25398,25422,25437,25649,25672,25700,25706,25746,25758,25797,25814,25913,26034,26231,26394,26409,26519,26620,26643,26677,26837,26956,27111,27113,27155,27222,27261,27298,27331,27372,27436,27460,27502,27516,27531,27552,27567,27623,27651,27685,27770,27817,27870,27912,27934,27978,28113,28139,28191,28515,28518,28521,28972,28973,28974,28979,28985,28986,28987,28989,28990,28991,28995,29001,29007,29008,29072,29225,29306,29479,29691,29991,30127,30214,30236,30558,30664,31175,31879,32039,32040,32049,32059,32145,32199,32352,32509,32513,32615,32628,32665,32765,32778,32779,32806,32817,32818,32852,32876,33432,33687,33954,34097,34215,34421,34425,34581,34637,34648,34741,35031,35173,35243,35246,35365,35618,35648,35802,35803,36023,36147,36423,36424,36514,36624,36856,36888,36903,36905,36911,37251,37354,37428,37473,37669,37916,38277,38287,38499,38724,38741,38870,38884,38896,39038,39183,39268,39430,39452,39767,39851,39893,40000,40002,40003,40020,40073,40247,40248,40370,40653,40716,40751,40938,41012,41013,41015,41051,41104,41196,41221,41282,41306,41309,41407,41431,41432,41433,41436,41437,41518,41520,41522,41669,41689,41690,41691,41721,41794,41796,41806,41807,41809,41862,41926,41927,41974,42017,42211,42220,42246,42315,42387,42392,42431,42508,42561,42665,42913,42968,43141,43315,43411,43412,43461,43576,43691,43755,43785,43868,44121,44129,44434,44436,44768,45008,45389,45831,46029,46129,46198,46590,46662,46774,46782,46867,47041,47042,47370,47481,47819,48118,48459,48467,48480,48535,48542,48590,48634,49256,49298,49313,49318,49324,49342,49362,49371,49380,49440,49467,49483,49566,49616,49639,49706,49765,49784,49841,49928,49946,50017,50110,50116,50124,50148,50164,50223,50249,50269,50282,50346,50366,50389,50394,50411,50425,50434,50586,50638,50651,51267,51319,51327,51336,51340,51440,51453,51498,51538,51644,51658,51739,51767,51796,51804,51943,52005,52634,52648,52722,52729,52822,53008,53229,53374,53418,53568,53587,53618,53677,53715,53727,53751,53811,53909,53924,53936,53943,53948,53952,53965,53976,53983,53994,53996,54076,54198,54274,54381,54416,54495,54517,54604,54674,54750,54794,55010,55130,55157,55216,55231,55236,55269,55374,55406,55410,55588,55629,55640,55667,55672,55678,55683,55737,55793,55819,55945,55960,56049,56055,56065,56113,56134,56176,56258,56277,56287,56335,56423,56424,56583,56799,56844,56862,56884,56885,56902,56903,56914,57020,57031,57124,57179,57274,57323,57391,57427,57432,57531,57617,57678,57772,57838,57844,57847,57852,57855,57926,58189,58232,58372,58376,58405,58421,58449,58478,58600,58612,58619,58705,58711,58749,58795,58960,58969,58971,58993,59011,59017,59107,59118,59135,59188,59195,59202,59206,59350,59364,59389,59428,59475,59500,59511,59545,59548,59567,59628,59820,59821,59825,59826,59828,59830,59833,59834,59840,59869,59910,59986,60021,60107,60194,60219,60225,60249,60331,60373,60427,60476,60488,60491,60533,60549,60554,60593,60653,60655,60730,60746,60763,60842,60843,60852,60867,60874,60880,60954,60965,60986,61000,61072,61075,61086,61089,61100,61286,61341,61490,61499,61601,61612,61613,61643,61784,61794,61836,61849,61877,62111,62160,62203,62207,62227,62249,62263,62279,62286,62321,62354,62363,62365,62415,62417,62447,62466,62474,62501,62513,62517,62541,62546,62563,62693,62706,62768,62775,62836,62919,62934,62991,62995,63030,63050,63114,63172,63215,63258,63273,63279,63281,63342,63388,63431,63436,63589,63596,63619,63626,63633,63680,63699,63780,63811,63899,64009,64035,64047,64128,64153,64179,64203,64219,64278,64317,64412,64415,64533,64547,64575,64591,64754,64757,64812,64959,65064,65279,65333,65485,65487)   AND IFNULL(stock.quantity, 0) > 0  AND IFNULL(p.price, 0) > 0
  130.                 GROUP BY product_shop.id_product
  131.                 ORDER BY CONVERT(p.reference, UNSIGNED INT) DESC
  132.                 ) UNION (SELECT
  133.             CONVERT(p.reference, UNSIGNED INT) AS reference, p.id_product, p.id_supplier, p.id_manufacturer, p.id_category_default, p.id_shop_default, p.id_tax_rules_group, p.on_sale, p.online_only, p.ean13,             p.upc, p.ecotax, p.minimal_quantity, p.price, p.wholesale_price, p.unity, p.unit_price_ratio, p.additional_shipping_cost, p.supplier_reference, p.location, p.width, p.height, p.depth, p.weight,
  134.             p.quantity_discount, p.customizable, p.uploadable_files, p.text_fields, p.active, p.redirect_type, p.id_product_redirected, p.available_for_order, p.available_date, p.condition,
  135.             p.show_price, p.indexed, p.visibility, p.cache_is_pack, p.cache_has_attachments, p.is_virtual, p.cache_default_attribute, p.date_add, p.date_upd, p.advanced_stock_management,
  136.             product_shop.id_shop
  137.             , stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity,
  138.                 pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
  139.              MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name ,(
  140.                 SELECT SUM(weight)
  141.                 FROM ps_search_word sw
  142.                 LEFT JOIN ps_search_index si ON sw.id_word = si.id_word
  143.                 WHERE sw.id_lang = 1
  144.                     AND sw.id_shop = 1
  145.                     AND si.id_product = p.id_product
  146.                     AND (sw.word LIKE 'faro%' OR sw.word LIKE 'derecho%')
  147.             ) POSITION, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
  148.                 DATEDIFF(
  149.                     p.`date_add`,
  150.                     DATE_SUB(
  151.                         NOW(),
  152.                         INTERVAL 3 DAY
  153.                     )
  154.                 ) > 0 NEW,
  155.                 IFNULL(feat2.VALUE, 0) AS reffab,
  156.                 IFNULL(feat4.VALUE, 0) AS refmarca
  157.                 FROM ps_product p
  158.                  INNER JOIN ps_product_shop product_shop
  159.         ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
  160.  
  161.                 INNER JOIN `ps_product_lang` pl ON (
  162.                     p.`id_product` = pl.`id_product`
  163.                     AND pl.`id_lang` = 1 AND pl.id_shop = 1
  164.                 )
  165.                 LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product`)
  166.                  LEFT JOIN ps_product_attribute_shop product_attribute_shop
  167.         ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1 AND product_attribute_shop.`default_on` = 1)
  168.                  LEFT
  169.             JOIN ps_stock_available stock
  170.             ON (stock.id_product = p.id_product AND stock.id_product_attribute = IFNULL(`product_attribute_shop`.id_product_attribute, 0) AND stock.id_shop = 1  )
  171.                 LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
  172.                 LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product`) LEFT JOIN ps_image_shop image_shop
  173.         ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)
  174.                 LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1)
  175.                 LEFT JOIN `ps_feature_product` feat1 ON (feat1.id_feature = 9 AND feat1.id_product = p.`id_product`)
  176.                 LEFT JOIN `ps_feature_value_lang` feat2 ON (feat1.id_feature_value = feat2.id_feature_value AND feat2.`id_lang` = 1)
  177.                 LEFT JOIN `ps_feature_product` feat3 ON (feat3.id_feature = 15 AND feat3.id_product = p.`id_product`)
  178.                 LEFT JOIN `ps_feature_value_lang` feat4 ON (feat3.id_feature_value = feat4.id_feature_value AND feat4.`id_lang` = 1)
  179.                 WHERE p.`id_product`  IN (247,690,724,851,858,865,1020,1097,1151,1152,1235,1414,1569,1575,1598,1673,1873,2087,2279,2280,2281,2283,2302,2458,2476,2663,2686,2824,2843,2923,3031,3113,3163,3236,3254,3454,3501,3770,3986,4147,4177,4203,4206,4207,4208,4210,4216,4217,4218,4225,4228,4229,4230,4232,4233,4235,4252,4254,4259,4263,4266,4267,4268,4269,4270,4274,4283,4284,4285,4287,4288,4289,4415,4644,5378,5409,5737,5760,5782,5856,5999,6396,6486,6541,6686,6687,6763,6786,6815,7022,7083,7084,7189,7199,7215,7270,7273,7275,7276,7278,7280,7292,7293,7294,7301,7303,7306,7307,7322,7324,7325,7331,7334,7337,7340,7341,7344,7346,7348,7420,7603,7609,7797,8027,8410,8562,8834,8958,9460,9526,9825,9834,10546,10776,11308,11370,11413,11491,11685,11899,12319,12335,12351,12352,12513,12553,12604,12647,12804,12824,13364,13568,13592,13621,13720,13754,13774,13806,13819,13836,13875,13893,14081,14152,14186,14230,14278,14290,14298,14317,14488,14570,14638,14639,14650,14663,14807,14829,14901,15205,15552,15587,15589,15781,15792,15923,15938,15994,16069,16097,16154,16234,16495,16559,16672,16700,16743,16771,16955,17029,17153,17689,17753,17824,18080,18150,18163,18208,18288,18352,18390,18485,18506,18532,18586,18686,18709,18726,18767,18859,18871,19058,19078,19080,19104,19220,19274,19276,19354,19379,19493,19530,19539,19770,19818,19891,19897,19993,20024,20297,20376,20398,20609,20702,20760,20791,20885,20890,20928,21039,21234,21311,21350,21404,21406,21524,21548,21592,21701,21804,21834,21841,21896,21988,22005,22007,22017,22033,22137,22204,22344,22375,22426,22449,22504,22630,22715,22867,22946,23045,23046,23078,23105,23311,23471,23543,23580,23623,23676,23721,23795,23881,23919,23929,24131,24138,24282,24315,24499,24531,24801,24843,24975,25014,25181,25195,25398,25422,25437,25649,25672,25700,25706,25746,25758,25797,25814,25913,26034,26231,26394,26409,26519,26620,26643,26677,26837,26956,27111,27113,27155,27222,27261,27298,27331,27372,27436,27460,27502,27516,27531,27552,27567,27623,27651,27685,27770,27817,27870,27912,27934,27978,28113,28139,28191,28515,28518,28521,28972,28973,28974,28979,28985,28986,28987,28989,28990,28991,28995,29001,29007,29008,29072,29225,29306,29479,29691,29991,30127,30214,30236,30558,30664,31175,31879,32039,32040,32049,32059,32145,32199,32352,32509,32513,32615,32628,32665,32765,32778,32779,32806,32817,32818,32852,32876,33432,33687,33954,34097,34215,34421,34425,34581,34637,34648,34741,35031,35173,35243,35246,35365,35618,35648,35802,35803,36023,36147,36423,36424,36514,36624,36856,36888,36903,36905,36911,37251,37354,37428,37473,37669,37916,38277,38287,38499,38724,38741,38870,38884,38896,39038,39183,39268,39430,39452,39767,39851,39893,40000,40002,40003,40020,40073,40247,40248,40370,40653,40716,40751,40938,41012,41013,41015,41051,41104,41196,41221,41282,41306,41309,41407,41431,41432,41433,41436,41437,41518,41520,41522,41669,41689,41690,41691,41721,41794,41796,41806,41807,41809,41862,41926,41927,41974,42017,42211,42220,42246,42315,42387,42392,42431,42508,42561,42665,42913,42968,43141,43315,43411,43412,43461,43576,43691,43755,43785,43868,44121,44129,44434,44436,44768,45008,45389,45831,46029,46129,46198,46590,46662,46774,46782,46867,47041,47042,47370,47481,47819,48118,48459,48467,48480,48535,48542,48590,48634,49256,49298,49313,49318,49324,49342,49362,49371,49380,49440,49467,49483,49566,49616,49639,49706,49765,49784,49841,49928,49946,50017,50110,50116,50124,50148,50164,50223,50249,50269,50282,50346,50366,50389,50394,50411,50425,50434,50586,50638,50651,51267,51319,51327,51336,51340,51440,51453,51498,51538,51644,51658,51739,51767,51796,51804,51943,52005,52634,52648,52722,52729,52822,53008,53229,53374,53418,53568,53587,53618,53677,53715,53727,53751,53811,53909,53924,53936,53943,53948,53952,53965,53976,53983,53994,53996,54076,54198,54274,54381,54416,54495,54517,54604,54674,54750,54794,55010,55130,55157,55216,55231,55236,55269,55374,55406,55410,55588,55629,55640,55667,55672,55678,55683,55737,55793,55819,55945,55960,56049,56055,56065,56113,56134,56176,56258,56277,56287,56335,56423,56424,56583,56799,56844,56862,56884,56885,56902,56903,56914,57020,57031,57124,57179,57274,57323,57391,57427,57432,57531,57617,57678,57772,57838,57844,57847,57852,57855,57926,58189,58232,58372,58376,58405,58421,58449,58478,58600,58612,58619,58705,58711,58749,58795,58960,58969,58971,58993,59011,59017,59107,59118,59135,59188,59195,59202,59206,59350,59364,59389,59428,59475,59500,59511,59545,59548,59567,59628,59820,59821,59825,59826,59828,59830,59833,59834,59840,59869,59910,59986,60021,60107,60194,60219,60225,60249,60331,60373,60427,60476,60488,60491,60533,60549,60554,60593,60653,60655,60730,60746,60763,60842,60843,60852,60867,60874,60880,60954,60965,60986,61000,61072,61075,61086,61089,61100,61286,61341,61490,61499,61601,61612,61613,61643,61784,61794,61836,61849,61877,62111,62160,62203,62207,62227,62249,62263,62279,62286,62321,62354,62363,62365,62415,62417,62447,62466,62474,62501,62513,62517,62541,62546,62563,62693,62706,62768,62775,62836,62919,62934,62991,62995,63030,63050,63114,63172,63215,63258,63273,63279,63281,63342,63388,63431,63436,63589,63596,63619,63626,63633,63680,63699,63780,63811,63899,64009,64035,64047,64128,64153,64179,64203,64219,64278,64317,64412,64415,64533,64547,64575,64591,64754,64757,64812,64959,65064,65279,65333,65485,65487)   AND IFNULL(stock.quantity, 0) > 0  AND IFNULL(p.price, 0) > 0
  180.                 GROUP BY product_shop.id_product
  181.                 ORDER BY CONVERT(p.reference, UNSIGNED INT) DESC
  182.                 ) UNION (SELECT
  183.             CONVERT(p.reference, UNSIGNED INT) AS reference, p.id_product, p.id_supplier, p.id_manufacturer, p.id_category_default, p.id_shop_default, p.id_tax_rules_group, p.on_sale, p.online_only, p.ean13,             p.upc, p.ecotax, p.minimal_quantity, p.price, p.wholesale_price, p.unity, p.unit_price_ratio, p.additional_shipping_cost, p.supplier_reference, p.location, p.width, p.height, p.depth, p.weight,
  184.             p.quantity_discount, p.customizable, p.uploadable_files, p.text_fields, p.active, p.redirect_type, p.id_product_redirected, p.available_for_order, p.available_date, p.condition,
  185.             p.show_price, p.indexed, p.visibility, p.cache_is_pack, p.cache_has_attachments, p.is_virtual, p.cache_default_attribute, p.date_add, p.date_upd, p.advanced_stock_management,
  186.             product_shop.id_shop
  187.             , stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity,
  188.                 pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
  189.              MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name ,(
  190.                 SELECT SUM(weight)
  191.                 FROM ps_search_word sw
  192.                 LEFT JOIN ps_search_index si ON sw.id_word = si.id_word
  193.                 WHERE sw.id_lang = 1
  194.                     AND sw.id_shop = 1
  195.                     AND si.id_product = p.id_product
  196.                     AND (sw.word LIKE 'faro%' OR sw.word LIKE 'derecho%')
  197.             ) POSITION, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
  198.                 DATEDIFF(
  199.                     p.`date_add`,
  200.                     DATE_SUB(
  201.                         NOW(),
  202.                         INTERVAL 3 DAY
  203.                     )
  204.                 ) > 0 NEW,
  205.                 IFNULL(feat2.VALUE, 0) AS reffab,
  206.                 IFNULL(feat4.VALUE, 0) AS refmarca
  207.                 FROM ps_product p
  208.                  INNER JOIN ps_product_shop product_shop
  209.         ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
  210.  
  211.                 INNER JOIN `ps_product_lang` pl ON (
  212.                     p.`id_product` = pl.`id_product`
  213.                     AND pl.`id_lang` = 1 AND pl.id_shop = 1
  214.                 )
  215.                 LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product`)
  216.                  LEFT JOIN ps_product_attribute_shop product_attribute_shop
  217.         ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1 AND product_attribute_shop.`default_on` = 1)
  218.                  LEFT
  219.             JOIN ps_stock_available stock
  220.             ON (stock.id_product = p.id_product AND stock.id_product_attribute = IFNULL(`product_attribute_shop`.id_product_attribute, 0) AND stock.id_shop = 1  )
  221.                 LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
  222.                 LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product`) LEFT JOIN ps_image_shop image_shop
  223.         ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)
  224.                 LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1)
  225.                 LEFT JOIN `ps_feature_product` feat1 ON (feat1.id_feature = 9 AND feat1.id_product = p.`id_product`)
  226.                 LEFT JOIN `ps_feature_value_lang` feat2 ON (feat1.id_feature_value = feat2.id_feature_value AND feat2.`id_lang` = 1)
  227.                 LEFT JOIN `ps_feature_product` feat3 ON (feat3.id_feature = 15 AND feat3.id_product = p.`id_product`)
  228.                 LEFT JOIN `ps_feature_value_lang` feat4 ON (feat3.id_feature_value = feat4.id_feature_value AND feat4.`id_lang` = 1)
  229.                 WHERE p.`id_product`  IN (247,690,724,851,858,865,1020,1097,1151,1152,1235,1414,1569,1575,1598,1673,1873,2087,2279,2280,2281,2283,2302,2458,2476,2663,2686,2824,2843,2923,3031,3113,3163,3236,3254,3454,3501,3770,3986,4147,4177,4203,4206,4207,4208,4210,4216,4217,4218,4225,4228,4229,4230,4232,4233,4235,4252,4254,4259,4263,4266,4267,4268,4269,4270,4274,4283,4284,4285,4287,4288,4289,4415,4644,5378,5409,5737,5760,5782,5856,5999,6396,6486,6541,6686,6687,6763,6786,6815,7022,7083,7084,7189,7199,7215,7270,7273,7275,7276,7278,7280,7292,7293,7294,7301,7303,7306,7307,7322,7324,7325,7331,7334,7337,7340,7341,7344,7346,7348,7420,7603,7609,7797,8027,8410,8562,8834,8958,9460,9526,9825,9834,10546,10776,11308,11370,11413,11491,11685,11899,12319,12335,12351,12352,12513,12553,12604,12647,12804,12824,13364,13568,13592,13621,13720,13754,13774,13806,13819,13836,13875,13893,14081,14152,14186,14230,14278,14290,14298,14317,14488,14570,14638,14639,14650,14663,14807,14829,14901,15205,15552,15587,15589,15781,15792,15923,15938,15994,16069,16097,16154,16234,16495,16559,16672,16700,16743,16771,16955,17029,17153,17689,17753,17824,18080,18150,18163,18208,18288,18352,18390,18485,18506,18532,18586,18686,18709,18726,18767,18859,18871,19058,19078,19080,19104,19220,19274,19276,19354,19379,19493,19530,19539,19770,19818,19891,19897,19993,20024,20297,20376,20398,20609,20702,20760,20791,20885,20890,20928,21039,21234,21311,21350,21404,21406,21524,21548,21592,21701,21804,21834,21841,21896,21988,22005,22007,22017,22033,22137,22204,22344,22375,22426,22449,22504,22630,22715,22867,22946,23045,23046,23078,23105,23311,23471,23543,23580,23623,23676,23721,23795,23881,23919,23929,24131,24138,24282,24315,24499,24531,24801,24843,24975,25014,25181,25195,25398,25422,25437,25649,25672,25700,25706,25746,25758,25797,25814,25913,26034,26231,26394,26409,26519,26620,26643,26677,26837,26956,27111,27113,27155,27222,27261,27298,27331,27372,27436,27460,27502,27516,27531,27552,27567,27623,27651,27685,27770,27817,27870,27912,27934,27978,28113,28139,28191,28515,28518,28521,28972,28973,28974,28979,28985,28986,28987,28989,28990,28991,28995,29001,29007,29008,29072,29225,29306,29479,29691,29991,30127,30214,30236,30558,30664,31175,31879,32039,32040,32049,32059,32145,32199,32352,32509,32513,32615,32628,32665,32765,32778,32779,32806,32817,32818,32852,32876,33432,33687,33954,34097,34215,34421,34425,34581,34637,34648,34741,35031,35173,35243,35246,35365,35618,35648,35802,35803,36023,36147,36423,36424,36514,36624,36856,36888,36903,36905,36911,37251,37354,37428,37473,37669,37916,38277,38287,38499,38724,38741,38870,38884,38896,39038,39183,39268,39430,39452,39767,39851,39893,40000,40002,40003,40020,40073,40247,40248,40370,40653,40716,40751,40938,41012,41013,41015,41051,41104,41196,41221,41282,41306,41309,41407,41431,41432,41433,41436,41437,41518,41520,41522,41669,41689,41690,41691,41721,41794,41796,41806,41807,41809,41862,41926,41927,41974,42017,42211,42220,42246,42315,42387,42392,42431,42508,42561,42665,42913,42968,43141,43315,43411,43412,43461,43576,43691,43755,43785,43868,44121,44129,44434,44436,44768,45008,45389,45831,46029,46129,46198,46590,46662,46774,46782,46867,47041,47042,47370,47481,47819,48118,48459,48467,48480,48535,48542,48590,48634,49256,49298,49313,49318,49324,49342,49362,49371,49380,49440,49467,49483,49566,49616,49639,49706,49765,49784,49841,49928,49946,50017,50110,50116,50124,50148,50164,50223,50249,50269,50282,50346,50366,50389,50394,50411,50425,50434,50586,50638,50651,51267,51319,51327,51336,51340,51440,51453,51498,51538,51644,51658,51739,51767,51796,51804,51943,52005,52634,52648,52722,52729,52822,53008,53229,53374,53418,53568,53587,53618,53677,53715,53727,53751,53811,53909,53924,53936,53943,53948,53952,53965,53976,53983,53994,53996,54076,54198,54274,54381,54416,54495,54517,54604,54674,54750,54794,55010,55130,55157,55216,55231,55236,55269,55374,55406,55410,55588,55629,55640,55667,55672,55678,55683,55737,55793,55819,55945,55960,56049,56055,56065,56113,56134,56176,56258,56277,56287,56335,56423,56424,56583,56799,56844,56862,56884,56885,56902,56903,56914,57020,57031,57124,57179,57274,57323,57391,57427,57432,57531,57617,57678,57772,57838,57844,57847,57852,57855,57926,58189,58232,58372,58376,58405,58421,58449,58478,58600,58612,58619,58705,58711,58749,58795,58960,58969,58971,58993,59011,59017,59107,59118,59135,59188,59195,59202,59206,59350,59364,59389,59428,59475,59500,59511,59545,59548,59567,59628,59820,59821,59825,59826,59828,59830,59833,59834,59840,59869,59910,59986,60021,60107,60194,60219,60225,60249,60331,60373,60427,60476,60488,60491,60533,60549,60554,60593,60653,60655,60730,60746,60763,60842,60843,60852,60867,60874,60880,60954,60965,60986,61000,61072,61075,61086,61089,61100,61286,61341,61490,61499,61601,61612,61613,61643,61784,61794,61836,61849,61877,62111,62160,62203,62207,62227,62249,62263,62279,62286,62321,62354,62363,62365,62415,62417,62447,62466,62474,62501,62513,62517,62541,62546,62563,62693,62706,62768,62775,62836,62919,62934,62991,62995,63030,63050,63114,63172,63215,63258,63273,63279,63281,63342,63388,63431,63436,63589,63596,63619,63626,63633,63680,63699,63780,63811,63899,64009,64035,64047,64128,64153,64179,64203,64219,64278,64317,64412,64415,64533,64547,64575,64591,64754,64757,64812,64959,65064,65279,65333,65485,65487)   AND IFNULL(stock.quantity, 0) > 0  AND IFNULL(p.price, 0) > 0
  230.                 GROUP BY product_shop.id_product
  231.                 ORDER BY CONVERT(p.reference, UNSIGNED INT) DESC
  232.                 ) UNION (SELECT
  233.             CONVERT(p.reference, UNSIGNED INT) AS reference, p.id_product, p.id_supplier, p.id_manufacturer, p.id_category_default, p.id_shop_default, p.id_tax_rules_group, p.on_sale, p.online_only, p.ean13,             p.upc, p.ecotax, p.minimal_quantity, p.price, p.wholesale_price, p.unity, p.unit_price_ratio, p.additional_shipping_cost, p.supplier_reference, p.location, p.width, p.height, p.depth, p.weight,
  234.             p.quantity_discount, p.customizable, p.uploadable_files, p.text_fields, p.active, p.redirect_type, p.id_product_redirected, p.available_for_order, p.available_date, p.condition,
  235.             p.show_price, p.indexed, p.visibility, p.cache_is_pack, p.cache_has_attachments, p.is_virtual, p.cache_default_attribute, p.date_add, p.date_upd, p.advanced_stock_management,
  236.             product_shop.id_shop
  237.             , stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity,
  238.                 pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
  239.              MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name ,(
  240.                 SELECT SUM(weight)
  241.                 FROM ps_search_word sw
  242.                 LEFT JOIN ps_search_index si ON sw.id_word = si.id_word
  243.                 WHERE sw.id_lang = 1
  244.                     AND sw.id_shop = 1
  245.                     AND si.id_product = p.id_product
  246.                     AND (sw.word LIKE 'faro%' OR sw.word LIKE 'derecho%')
  247.             ) POSITION, MAX(product_attribute_shop.`id_product_attribute`) id_product_attribute,
  248.                 DATEDIFF(
  249.                     p.`date_add`,
  250.                     DATE_SUB(
  251.                         NOW(),
  252.                         INTERVAL 3 DAY
  253.                     )
  254.                 ) > 0 NEW,
  255.                 IFNULL(feat2.VALUE, 0) AS reffab,
  256.                 IFNULL(feat4.VALUE, 0) AS refmarca
  257.                 FROM ps_product p
  258.                  INNER JOIN ps_product_shop product_shop
  259.         ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
  260.  
  261.                 INNER JOIN `ps_product_lang` pl ON (
  262.                     p.`id_product` = pl.`id_product`
  263.                     AND pl.`id_lang` = 1 AND pl.id_shop = 1
  264.                 )
  265.                 LEFT JOIN `ps_product_attribute` pa ON (p.`id_product` = pa.`id_product`)
  266.                  LEFT JOIN ps_product_attribute_shop product_attribute_shop
  267.         ON (product_attribute_shop.id_product_attribute = pa.id_product_attribute AND product_attribute_shop.id_shop = 1 AND product_attribute_shop.`default_on` = 1)
  268.                  LEFT
  269.             JOIN ps_stock_available stock
  270.             ON (stock.id_product = p.id_product AND stock.id_product_attribute = IFNULL(`product_attribute_shop`.id_product_attribute, 0) AND stock.id_shop = 1  )
  271.                 LEFT JOIN `ps_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
  272.                 LEFT JOIN `ps_image` i ON (i.`id_product` = p.`id_product`) LEFT JOIN ps_image_shop image_shop
  273.         ON (image_shop.id_image = i.id_image AND image_shop.id_shop = 1 AND image_shop.cover=1)
  274.                 LEFT JOIN `ps_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = 1)
  275.                 LEFT JOIN `ps_feature_product` feat1 ON (feat1.id_feature = 9 AND feat1.id_product = p.`id_product`)
  276.                 LEFT JOIN `ps_feature_value_lang` feat2 ON (feat1.id_feature_value = feat2.id_feature_value AND feat2.`id_lang` = 1)
  277.                 LEFT JOIN `ps_feature_product` feat3 ON (feat3.id_feature = 15 AND feat3.id_product = p.`id_product`)
  278.                 LEFT JOIN `ps_feature_value_lang` feat4 ON (feat3.id_feature_value = feat4.id_feature_value AND feat4.`id_lang` = 1)
  279.                 WHERE p.`id_product`  IN (43,247,690,724,851,858,865,1020,1097,1151,1152,1235,1392,1414,1521,1569,1575,1598,1652,1673,1873,1893,1938,2087,2279,2280,2281,2283,2302,2458,2476,2633,2663,2686,2744,2797,2824,2843,2923,3031,3113,3139,3163,3236,3254,3334,3454,3501,3747,3770,3986,4087,4147,4177,4203,4206,4207,4208,4210,4216,4217,4218,4224,4225,4228,4229,4230,4232,4233,4235,4252,4254,4259,4263,4266,4267,4268,4269,4270,4274,4283,4284,4285,4287,4288,4289,4359,4415,4644,4652,5030,5378,5409,5737,5760,5782,5856,5999,6195,6396,6486,6541,6686,6687,6763,6786,6815,6893,7022,7083,7084,7189,7199,7215,7223,7270,7273,7275,7276,7278,7280,7292,7293,7294,7301,7303,7306,7307,7322,7324,7325,7331,7334,7337,7340,7341,7344,7346,7348,7420,7527,7603,7609,7797,7960,7968,8027,8410,8562,8790,8834,8958,9460,9526,9825,9834,10102,10546,10567,10776,11308,11370,11413,11491,11545,11653,11685,11899,12319,12335,12351,12352,12513,12553,12604,12637,12647,12804,12824,12944,13283,13364,13561,13568,13592,13621,13696,13720,13754,13774,13806,13819,13836,13875,13893,13907,14081,14152,14186,14230,14278,14290,14298,14317,14488,14570,14638,14639,14650,14663,14721,14799,14807,14829,14901,15151,15205,15225,15328,15552,15587,15589,15753,15781,15792,15823,15923,15938,15994,16069,16072,16097,16103,16154,16234,16290,16323,16495,16496,16559,16672,16700,16713,16743,16771,16955,17029,17153,17689,17753,17824,17919,17974,18080,18150,18163,18208,18256,18288,18316,18352,18390,18431,18434,18485,18506,18532,18586,18686,18709,18726,18767,18848,18859,18871,19047,19056,19058,19078,19080,19104,19161,19220,19274,19276,19313,19354,19379,19469,19470,19493,19530,19533,19539,19770,19818,19891,19897,19931,19993,20024,20240,20280,20297,20376,20398,20403,20548,20609,20702,20760,20791,20793,20852,20885,20890,20928,20966,21039,21234,21311,21314,21350,21404,21406,21430,21524,21548,21592,21594,21701,21804,21834,21841,21896,21988,22005,22007,22016,22017,22033,22137,22172,22204,22344,22375,22426,22449,22504,22630,22665,22715,22867,22946,22980,23045,23046,23078,23105,23311,23408,23471,23543,23580,23623,23676,23721,23795,23801,23881,23919,23923,23929,24018,24027,24131,24138,24143,24171,24282,24315,24378,24398,24499,24531,24631,24776,24801,24843,24934,24975,25014,25085,25181,25195,25396,25398,25405,25422,25437,25439,25649,25672,25700,25706,25746,25758,25797,25814,25815,25913,25936,26034,26036,26231,26366,26394,26409,26519,26620,26643,26677,26837,26909,26956,27111,27113,27155,27171,27222,27261,27298,27331,27372,27436,27452,27460,27502,27516,27531,27552,27567,27572,27623,27651,27685,27770,27817,27870,27879,27912,27934,27947,27978,28113,28117,28139,28191,28515,28516,28518,28521,28523,28972,28973,28974,28979,28985,28986,28987,28989,28990,28991,28995,29001,29007,29008,29072,29225,29306,29479,29691,29991,30127,30214,30236,30558,30635,30664,31175,31251,31879,32039,32040,32049,32059,32145,32199,32351,32352,32428,32509,32513,32541,32612,32615,32628,32665,32765,32778,32779,32806,32817,32818,32852,32876,33417,33432,33687,33954,34097,34108,34215,34421,34425,34518,34581,34637,34648,34741,34992,35031,35173,35243,35246,35334,35365,35618,35648,35802,35803,36023,36147,36423,36424,36514,36624,36856,36888,36903,36905,36911,37036,37052,37251,37354,37428,37473,37669,37916,38277,38287,38345,38499,38724,38741,38809,38865,38870,38884,38896,38912,39038,39183,39184,39268,39430,39452,39715,39767,39851,39893,40000,40002,40003,40020,40031,40073,40247,40248,40370,40387,40399,40653,40716,40751,40938,41012,41013,41015,41051,41104,41196,41221,41282,41306,41309,41407,41431,41432,41433,41436,41437,41518,41520,41522,41586,41669,41689,41690,41691,41721,41794,41796,41806,41807,41809,41822,41862,41926,41927,41974,42017,42211,42220,42246,42286,42287,42315,42387,42392,42431,42508,42561,42665,42913,42968,43141,43315,43411,43412,43461,43576,43691,43755,43785,43868,44121,44129,44186,44287,44434,44436,44768,45008,45053,45389,45831,46029,46129,46198,46499,46590,46662,46697,46774,46782,46867,46951,47041,47042,47370,47481,47559,47809,47819,48118,48459,48467,48480,48509,48535,48542,48568,48590,48634,49256,49298,49313,49318,49324,49342,49362,49371,49376,49380,49429,49440,49467,49483,49566,49616,49639,49658,49706,49765,49784,49839,49841,49897,49926,49928,49946,50017,50079,50110,50116,50124,50148,50164,50223,50249,50269,50280,50282,50346,50366,50389,50394,50411,50425,50434,50586,50599,50627,50638,50651,51256,51267,51319,51327,51329,51334,51336,51340,51440,51453,51498,51524,51538,51644,51649,51658,51671,51739,51767,51796,51804,51809,51941,51943,52005,52031,52634,52646,52648,52722,52729,52822,53008,53079,53219,53229,53372,53374,53418,53448,53568,53572,53587,53598,53618,53677,53715,53727,53751,53811,53899,53909,53924,53936,53943,53948,53952,53965,53976,53983,53994,53996,54076,54128,54198,54252,54274,54325,54381,54416,54471,54495,54517,54602,54604,54674,54750,54794,55010,55130,55157,55216,55227,55229,55231,55236,55269,55374,55406,55410,55588,55629,55640,55667,55672,55678,55683,55737,55793,55819,55901,55902,55903,55945,55954,55960,56049,56055,56065,56113,56117,56123,56134,56176,56258,56277,56287,56335,56370,56423,56424,56583,56799,56829,56831,56844,56862,56884,56885,56902,56903,56914,57020,57031,57124,57179,57274,57323,57380,57391,57427,57432,57531,57617,57678,57772,57836,57838,57844,57847,57852,57855,57860,57926,57927,57998,58011,58189,58232,58372,58376,58405,58414,58421,58449,58478,58600,58612,58619,58621,58705,58711,58749,58785,58795,58803,58960,58969,58971,58993,59003,59011,59017,59107,59118,59135,59188,59195,59202,59206,59207,59350,59364,59368,59389,59428,59438,59475,59500,59511,59545,59548,59567,59571,59628,59633,59755,59762,59805,59820,59821,59825,59826,59828,59830,59833,59834,59840,59869,59910,59986,60021,60107,60136,60194,60219,60225,60249,60331,60372,60373,60427,60476,60488,60491,60533,60549,60554,60593,60650,60653,60655,60730,60746,60763,60831,60842,60843,60846,60847,60851,60852,60867,60874,60877,60880,60954,60965,60986,61000,61072,61075,61086,61089,61100,61243,61284,61286,61341,61444,61490,61499,61508,61601,61612,61613,61636,61641,61643,61691,61713,61784,61794,61806,61807,61836,61849,61856,61870,61877,62075,62105,62111,62124,62160,62162,62201,62203,62207,62227,62249,62263,62279,62286,62321,62354,62363,62365,62415,62417,62447,62466,62474,62501,62513,62517,62531,62541,62546,62562,62563,62693,62700,62706,62768,62775,62780,62836,62843,62919,62934,62991,62993,62995,63001,63030,63050,63065,63114,63115,63172,63215,63221,63258,63273,63279,63281,63290,63306,63342,63343,63388,63431,63436,63589,63596,63619,63626,63633,63680,63699,63727,63770,63780,63811,63899,64009,64035,64047,64074,64102,64128,64153,64179,64198,64203,64219,64278,64317,64330,64412,64415,64513,64533,64547,64575,64591,64610,64619,64754,64757,64812,64959,65064,65234,65279,65333,65473,65485,65487)   AND IFNULL(stock.quantity, 0) > 0  AND IFNULL(p.price, 0) > 0
  280.                 GROUP BY product_shop.id_product
  281.                 ORDER BY CONVERT(p.reference, UNSIGNED INT) DESC
  282.                 )) a ORDER BY a.reference DESC ) abc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement