SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  IF(
    shared_descr.product_id IS NOT NULL, 
    shared_descr.product, descr1.product
  ) as product, 
  stoc_intern, 
  pret_achizitie, 
  pret_revanzator, 
  gestiune 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_options_inventory as inventory ON inventory.product_id = products.product_id 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'ro' 
  LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  LEFT JOIN cscart_ult_product_descriptions shared_descr ON shared_descr.product_id = products.product_id 
  AND shared_descr.company_id = 1 
  AND shared_descr.lang_code = 'ro' 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  1 
  AND cscart_categories.category_id IN (
    19343, 
    19344, 
    19345, 
    19346, 
    19829, 
    21119, 
    21187, 
    21393, 
    21396, 
    21398, 
    19609, 
    19610, 
    19722, 
    19723, 
    21204, 
    21462, 
    19886, 
    19887, 
    20035, 
    20036, 
    20048, 
    20049, 
    20743, 
    21230, 
    21414, 
    21417, 
    20093, 
    20094, 
    20141, 
    20142, 
    20168, 
    20169, 
    20172, 
    20176, 
    21428, 
    20184, 
    20185, 
    20195, 
    20206, 
    20217, 
    21432, 
    21434, 
    20291, 
    20292, 
    20320, 
    20321, 
    21442, 
    21444, 
    21448, 
    21498, 
    20335, 
    20336, 
    20348, 
    20351, 
    20352, 
    20353, 
    20354, 
    20386, 
    21203, 
    21458, 
    21460, 
    21586, 
    20408, 
    20409, 
    21407, 
    21408, 
    21585, 
    20484, 
    20485, 
    20505, 
    20506, 
    21470, 
    20521, 
    20522, 
    21207, 
    21471, 
    20557, 
    20558, 
    20612, 
    20613, 
    20614, 
    20615, 
    21477, 
    21479, 
    20726, 
    20727, 
    21235, 
    21236, 
    21237, 
    21344, 
    21485, 
    21493, 
    21495, 
    21497, 
    20987, 
    20992, 
    21052, 
    21055, 
    21190, 
    21191, 
    21403, 
    21450, 
    21196, 
    21197, 
    21231, 
    21419, 
    21420, 
    21422, 
    21426, 
    21233, 
    21234, 
    21480, 
    21483, 
    21436, 
    21437, 
    21573, 
    21574, 
    19347, 
    19348, 
    19516, 
    19939, 
    21007, 
    21384, 
    21591, 
    19473, 
    19484, 
    19503, 
    19504, 
    19505, 
    21200, 
    19602, 
    19603, 
    19973, 
    19831, 
    19832, 
    19833, 
    19861, 
    19870, 
    21188, 
    21392, 
    21499, 
    21501, 
    19922, 
    19923, 
    21189, 
    21192, 
    19991, 
    19992, 
    20055, 
    20056, 
    20086, 
    20087, 
    20100, 
    20101, 
    20105, 
    20132, 
    21424, 
    21427, 
    21505, 
    20188, 
    20189, 
    21435, 
    20230, 
    20231, 
    21199, 
    20261, 
    20262, 
    20270, 
    20338, 
    20339, 
    20345, 
    20346, 
    21391, 
    20380, 
    20381, 
    21454, 
    21455, 
    21456, 
    21459, 
    21500, 
    20422, 
    20423, 
    21461, 
    20525, 
    20526, 
    20542, 
    21208, 
    21209, 
    21319, 
    20664, 
    20665, 
    20676, 
    20692, 
    20701, 
    20707, 
    20723, 
    21222, 
    21484, 
    21490, 
    21492, 
    21494, 
    21012, 
    21134, 
    21135, 
    21186, 
    21217, 
    21218, 
    21476, 
    21205, 
    21206, 
    21320, 
    21575, 
    21213, 
    21214, 
    21475, 
    21430, 
    21431, 
    21463, 
    21464, 
    21509, 
    19661, 
    19662, 
    19663, 
    20155, 
    21429, 
    19735, 
    19736, 
    21478, 
    19849, 
    19850, 
    21229, 
    21394, 
    19884, 
    19885, 
    19918, 
    19919, 
    21401, 
    19940, 
    19941, 
    19952, 
    19981, 
    19982, 
    20052, 
    20053, 
    20054, 
    20077, 
    20078, 
    20097, 
    20098, 
    21195, 
    21425, 
    21504, 
    20139, 
    20140, 
    20186, 
    20187, 
    20196, 
    20249, 
    20250, 
    20251, 
    21440, 
    20294, 
    20295, 
    20312, 
    20322, 
    21441, 
    21443, 
    21445, 
    21449, 
    20374, 
    20375, 
    20469, 
    21453, 
    20640, 
    20641, 
    21481, 
    20681, 
    20688, 
    20691, 
    20706, 
    20722, 
    21487, 
    21491, 
    21071, 
    21120, 
    21121, 
    21198, 
    21212, 
    21474, 
    21451, 
    21452, 
    21465, 
    21466, 
    21472, 
    21473, 
    19835, 
    19836, 
    19837, 
    21395, 
    21397, 
    19909, 
    19910, 
    19930, 
    19934, 
    19938, 
    21316, 
    21317, 
    21402, 
    21404, 
    21406, 
    20128, 
    20129, 
    20744, 
    21421, 
    21423, 
    20159, 
    20160, 
    20213, 
    20214, 
    21433, 
    20232, 
    20233, 
    20420, 
    20421, 
    20699, 
    20700, 
    20703, 
    21221, 
    21225, 
    21496, 
    21058, 
    21059, 
    21232, 
    21457, 
    21210, 
    21211, 
    21318, 
    21215, 
    21216, 
    21399, 
    21400, 
    21409, 
    21410, 
    21411, 
    21412, 
    21413, 
    21418, 
    21438, 
    21439, 
    21446, 
    21447, 
    21467, 
    21468, 
    21469, 
    21486, 
    21506, 
    21507, 
    19862, 
    19863, 
    20704, 
    21122, 
    19868, 
    19869, 
    20083, 
    20163, 
    20674, 
    21239, 
    21523, 
    36369, 
    19915, 
    19916, 
    19917, 
    19933, 
    21405, 
    19996, 
    19997, 
    20315, 
    20349, 
    20350, 
    20655, 
    20656, 
    21482, 
    20689, 
    20690, 
    21488, 
    21489, 
    21193, 
    21194, 
    21201, 
    21202, 
    21219, 
    21220, 
    21415, 
    21416, 
    21589, 
    21590, 
    20113, 
    20394, 
    20395, 
    20433, 
    20547, 
    20548, 
    20956, 
    21043, 
    21074
  ) 
  AND cscart_categories.company_id = 1 
  AND (
    CASE products.tracking WHEN 'O' THEN inventory.amount > 0 WHEN 'B' THEN products.amount > 0 ELSE 1 END
  ) 
  AND (
    products.usergroup_ids = '' 
    OR FIND_IN_SET(0, products.usergroup_ids) 
    OR FIND_IN_SET(1, products.usergroup_ids)
  ) 
  AND products.status IN ('A') 
  AND prices.usergroup_id IN (0, 0, 1) 
GROUP BY 
  products.product_id 
ORDER BY 
  popularity.total desc, 
  product_id ASC 
LIMIT 
  0, 16

Query time 0.00724

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "428.64"
    },
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "inventory",
              "access_type": "system",
              "possible_keys": [
                "pc"
              ],
              "rows_examined_per_scan": 0,
              "rows_produced_per_join": 1,
              "filtered": "0.00",
              "const_row_not_found": true,
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.10",
                "prefix_cost": "0.00",
                "data_read_per_join": "880"
              },
              "used_columns": [
                "product_id",
                "amount"
              ]
            }
          },
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "range",
              "possible_keys": [
                "PRIMARY",
                "c_status",
                "p_category_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "rows_examined_per_scan": 405,
              "rows_produced_per_join": 8,
              "filtered": "2.00",
              "cost_info": {
                "read_cost": "378.39",
                "eval_cost": "0.81",
                "prefix_cost": "379.20",
                "data_read_per_join": "21K"
              },
              "used_columns": [
                "category_id",
                "company_id",
                "usergroup_ids",
                "status"
              ],
              "attached_condition": "((`maniamall_cscart`.`cscart_categories`.`company_id` = 1) and (`maniamall_cscart`.`cscart_categories`.`category_id` in (19343,19344,19345,19346,19829,21119,21187,21393,21396,21398,19609,19610,19722,19723,21204,21462,19886,19887,20035,20036,20048,20049,20743,21230,21414,21417,20093,20094,20141,20142,20168,20169,20172,20176,21428,20184,20185,20195,20206,20217,21432,21434,20291,20292,20320,20321,21442,21444,21448,21498,20335,20336,20348,20351,20352,20353,20354,20386,21203,21458,21460,21586,20408,20409,21407,21408,21585,20484,20485,20505,20506,21470,20521,20522,21207,21471,20557,20558,20612,20613,20614,20615,21477,21479,20726,20727,21235,21236,21237,21344,21485,21493,21495,21497,20987,20992,21052,21055,21190,21191,21403,21450,21196,21197,21231,21419,21420,21422,21426,21233,21234,21480,21483,21436,21437,21573,21574,19347,19348,19516,19939,21007,21384,21591,19473,19484,19503,19504,19505,21200,19602,19603,19973,19831,19832,19833,19861,19870,21188,21392,21499,21501,19922,19923,21189,21192,19991,19992,20055,20056,20086,20087,20100,20101,20105,20132,21424,21427,21505,20188,20189,21435,20230,20231,21199,20261,20262,20270,20338,20339,20345,20346,21391,20380,20381,21454,21455,21456,21459,21500,20422,20423,21461,20525,20526,20542,21208,21209,21319,20664,20665,20676,20692,20701,20707,20723,21222,21484,21490,21492,21494,21012,21134,21135,21186,21217,21218,21476,21205,21206,21320,21575,21213,21214,21475,21430,21431,21463,21464,21509,19661,19662,19663,20155,21429,19735,19736,21478,19849,19850,21229,21394,19884,19885,19918,19919,21401,19940,19941,19952,19981,19982,20052,20053,20054,20077,20078,20097,20098,21195,21425,21504,20139,20140,20186,20187,20196,20249,20250,20251,21440,20294,20295,20312,20322,21441,21443,21445,21449,20374,20375,20469,21453,20640,20641,21481,20681,20688,20691,20706,20722,21487,21491,21071,21120,21121,21198,21212,21474,21451,21452,21465,21466,21472,21473,19835,19836,19837,21395,21397,19909,19910,19930,19934,19938,21316,21317,21402,21404,21406,20128,20129,20744,21421,21423,20159,20160,20213,20214,21433,20232,20233,20420,20421,20699,20700,20703,21221,21225,21496,21058,21059,21232,21457,21210,21211,21318,21215,21216,21399,21400,21409,21410,21411,21412,21413,21418,21438,21439,21446,21447,21467,21468,21469,21486,21506,21507,19862,19863,20704,21122,19868,19869,20083,20163,20674,21239,21523,36369,19915,19916,19917,19933,21405,19996,19997,20315,20349,20350,20655,20656,21482,20689,20690,21488,21489,21193,21194,21201,21202,21219,21220,21415,21416,21589,21590,20113,20394,20395,20433,20547,20548,20956,21043,21074)) and ((`maniamall_cscart`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`maniamall_cscart`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`maniamall_cscart`.`cscart_categories`.`usergroup_ids`))) and (`maniamall_cscart`.`cscart_categories`.`status` in ('A','H')))"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "pt"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "maniamall_cscart.cscart_categories.category_id"
              ],
              "rows_examined_per_scan": 19,
              "rows_produced_per_join": 157,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "8.00",
                "eval_cost": "15.78",
                "prefix_cost": "402.98",
                "data_read_per_join": "2K"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "status"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "maniamall_cscart.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "5.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.79",
                "prefix_cost": "418.76",
                "data_read_per_join": "34K"
              },
              "used_columns": [
                "product_id",
                "status",
                "amount",
                "usergroup_ids",
                "tracking",
                "stoc_intern",
                "pret_achizitie",
                "pret_revanzator",
                "gestiune"
              ],
              "attached_condition": "((0 <> (case `maniamall_cscart`.`products`.`tracking` when 'O' then <cache>((NULL > 0)) when 'B' then (`maniamall_cscart`.`products`.`amount` > 0) else 1 end)) and ((`maniamall_cscart`.`products`.`usergroup_ids` = '') or (0 <> find_in_set(0,`maniamall_cscart`.`products`.`usergroup_ids`)) or (0 <> find_in_set(1,`maniamall_cscart`.`products`.`usergroup_ids`))) and (`maniamall_cscart`.`products`.`status` = 'A'))"
            }
          },
          {
            "table": {
              "table_name": "shared_descr",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "product_id",
                "company_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "lang_code",
                "company_id"
              ],
              "key_length": "13",
              "ref": [
                "maniamall_cscart.products_categories.product_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.79",
                "prefix_cost": "419.55",
                "data_read_per_join": "30K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "company_id",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "descr1",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "product_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id",
                "lang_code"
              ],
              "key_length": "9",
              "ref": [
                "maniamall_cscart.products_categories.product_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.79",
                "prefix_cost": "420.34",
                "data_read_per_join": "30K"
              },
              "used_columns": [
                "product_id",
                "lang_code",
                "product"
              ]
            }
          },
          {
            "table": {
              "table_name": "popularity",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "total"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "maniamall_cscart.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 7,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.00",
                "eval_cost": "0.79",
                "prefix_cost": "421.13",
                "data_read_per_join": "252"
              },
              "used_columns": [
                "product_id",
                "total"
              ]
            }
          },
          {
            "table": {
              "table_name": "prices",
              "access_type": "ref",
              "possible_keys": [
                "usergroup",
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "key": "lower_limit",
              "used_key_parts": [
                "lower_limit",
                "product_id"
              ],
              "key_length": "6",
              "ref": [
                "const",
                "maniamall_cscart.products_categories.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 3,
              "filtered": "50.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "6.72",
                "eval_cost": "0.39",
                "prefix_cost": "428.64",
                "data_read_per_join": "94"
              },
              "used_columns": [
                "product_id",
                "lower_limit",
                "usergroup_id"
              ],
              "attached_condition": "(`maniamall_cscart`.`prices`.`usergroup_id` in (0,0,1))"
            }
          }
        ]
      }
    }
  }
}

Result

product_id product stoc_intern pret_achizitie pret_revanzator gestiune
1067678 Stop spate lampa Audi A4 B6 COMBI / Estate / Avant 11.2000-11.2004 BestAutoVest partea Stanga, Depo Kft Auto -99 0.00 0.00 N
1731948 Lampi LED semnalizare OGLINDA dinamica compatibila Mercedes W205, W213, W217, W222 COD: OR-5005D-1 MRA36-190521-7 -99 227.27 0.00 Y
1068147 Lampa semnalizare oglinda Honda CRV (RM) 11.2011- ; Accord (Usa) 09.2012-; Civic (Fb) Hatchback/Combi 01.2012- ; Jazz 09.2015- , semnalizator partea Fata Dreapta, Led, Ece , Taiwan, 34300TV0E01 Kft Auto -99 0.00 0.00 Y
1731949 Lampi LED semnalizare OGLINDA dinamica compatibila BMW F20, F21, F22, F30, F31, F32, F33, F34, F35, F36 COD: OR-5004D-1 MRA36-190521-6 -99 227.27 0.00 Y