SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  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_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 7191 
WHERE 
  cscart_products_categories.product_id IN (
    90007, 89766, 89767, 82864, 82865, 82937, 
    82938, 83010, 83011, 83446, 83447, 
    83451, 83452, 84802, 84803, 91082, 
    82718, 82719, 83456, 83457, 89764, 
    86470, 86746, 82862, 82935, 83008, 
    83444, 83449, 82716, 83454, 86609, 
    86610, 86678, 86679, 83022, 83023, 
    90858, 90859, 90937, 90938, 89765, 
    86607, 86676, 82863, 82936, 83009, 
    83445, 83450, 83020, 90856, 90935, 
    82717, 83455, 83079, 83080, 83577, 
    83579, 90916, 90918, 90995, 90997, 
    83077, 83574, 90913, 90992, 90003, 
    83078, 83575, 90914, 90993, 86608, 
    86677, 82803, 82804, 82876, 82877, 
    82949, 82950, 83021, 90857, 90936, 
    91102, 91103, 91188, 91189, 91243, 
    91244, 89803, 89804, 89855, 89856, 
    89927, 89928, 91493, 91494, 89801
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00425

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "115.54"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 203,
            "rows_produced_per_join": 203,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "20.63",
              "eval_cost": "20.30",
              "prefix_cost": "40.93",
              "data_read_per_join": "3K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (90007,89766,89767,82864,82865,82937,82938,83010,83011,83446,83447,83451,83452,84802,84803,91082,82718,82719,83456,83457,89764,86470,86746,82862,82935,83008,83444,83449,82716,83454,86609,86610,86678,86679,83022,83023,90858,90859,90937,90938,89765,86607,86676,82863,82936,83009,83445,83450,83020,90856,90935,82717,83455,83079,83080,83577,83579,90916,90918,90995,90997,83077,83574,90913,90992,90003,83078,83575,90914,90993,86608,86677,82803,82804,82876,82877,82949,82950,83021,90857,90936,91102,91103,91188,91189,91243,91244,89803,89804,89855,89856,89927,89928,91493,91494,89801))"
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 10,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "50.75",
              "eval_cost": "1.02",
              "prefix_cost": "111.98",
              "data_read_per_join": "26K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 10,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.54",
              "eval_cost": "1.02",
              "prefix_cost": "115.54",
              "data_read_per_join": "162"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82716 7170,7191M 0
82717 7170,7191M 0
82718 7170,7191M 0
82719 7170,7191M 0
82803 7170,7191M 0
82804 7170,7191M 0
82862 7170,7191M 0
82863 7170,7191M 0
82864 7170,7191M 0
82865 7170,7191M 0
82876 7170,7191M 0
82877 7170,7191M 0
82935 7170,7191M 0
82936 7170,7191M 0
82937 7170,7191M 0
82938 7170,7191M 0
82949 7170,7191M 0
82950 7170,7191M 0
83008 7170,7191M 0
83009 7170,7191M 0
83010 7170,7191M 0
83011 7170,7191M 0
83020 7170,7191M 0
83021 7170,7191M 0
83022 7170,7191M 0
83023 7170,7191M 0
83077 7170,7191M 0
83078 7170,7191M 0
83079 7170,7191M 0
83080 7170,7191M 0
83444 7170,7191M 0
83445 7170,7191M 0
83446 7170,7191M 0
83447 7170,7191M 0
83449 7170,7191M 0
83450 7170,7191M 0
83451 7170,7191M 0
83452 7170,7191M 0
83454 7170,7191M 0
83455 7170,7191M 0
83456 7170,7191M 0
83457 7170,7191M 0
83574 7170,7191M 0
83575 7170,7191M 0
83577 7170,7191M 0
83579 7170,7191M 0
84802 7170,7191M 0
84803 7170,7191M 0
86470 7170,7191,7310M 0
86607 7170,7191,7310M 0
86608 7170,7191,7310M 0
86609 7170,7191,7310M 0
86610 7170,7191,7310M 0
86676 7170,7191,7310M 0
86677 7170,7191,7310M 0
86678 7170,7191,7310M 0
86679 7170,7191,7310M 0
86746 7170,7191M 0
89764 7170,7191M 0
89765 7170,7191M 0
89766 7170,7191M 0
89767 7170,7191M 0
89801 7170,7191M 0
89803 7170,7191M 0
89804 7170,7191M 0
89855 7170,7191M 0
89856 7170,7191M 0
89927 7170,7191,7310M 0
89928 7170,7191,7310M 0
90003 7170,7191M 0
90007 7170,7191M 0
90856 7191,7170M 0
90857 7191,7170M 0
90858 7191,7170M 0
90859 7191,7170M 0
90913 7191,7170M 0
90914 7191,7170M 0
90916 7191,7170M 0
90918 7191,7170M 0
90935 7191,7170M 0
90936 7191,7170M 0
90937 7191,7170M 0
90938 7191,7170M 0
90992 7191,7170M 0
90993 7191,7170M 0
90995 7191,7170M 0
90997 7191,7170M 0
91082 7191,7170M 0
91102 7191,7170M 0
91103 7191,7170M 0
91188 7191,7170M 0
91189 7191,7170M 0
91243 7191,7170M 0
91244 7191,7170M 0
91493 7191,7170M 0
91494 7191,7170M 0