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 = 7211 
WHERE 
  cscart_products_categories.product_id IN (
    87640, 87876, 88506, 88507, 88510, 87987, 
    90828, 87632, 88561, 87637, 90827, 
    87938, 87941, 87997, 88026, 87781, 
    87882, 87988, 88047, 88048, 88050, 
    88051, 88052, 88053, 88054, 87990, 
    87961, 87875, 87937, 87950, 87959, 
    88798, 90826, 87952, 88004, 87998, 
    88000, 87881, 88031, 87948, 88702, 
    88749, 87945, 87942, 87964, 88029, 
    88018, 88021, 88799, 88006, 88013, 
    88015, 87972, 88703, 88750, 87944, 
    88595, 88154, 87874, 87783, 87880, 
    87873, 88797, 87782, 88701, 88748, 
    88596, 88594, 92893, 92894, 93002, 
    93003, 93004, 93005, 93006, 93007, 
    93008, 93009, 93010, 93011, 93012, 
    93013, 93014, 93015, 93341, 93342, 
    93343, 93344, 93345, 93346, 93347, 
    93348, 93349, 93350, 93351, 93352
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00134

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "174.03"
    },
    "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": 306,
            "rows_produced_per_join": 306,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "30.97",
              "eval_cost": "30.60",
              "prefix_cost": "61.57",
              "data_read_per_join": "4K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (87640,87876,88506,88507,88510,87987,90828,87632,88561,87637,90827,87938,87941,87997,88026,87781,87882,87988,88047,88048,88050,88051,88052,88053,88054,87990,87961,87875,87937,87950,87959,88798,90826,87952,88004,87998,88000,87881,88031,87948,88702,88749,87945,87942,87964,88029,88018,88021,88799,88006,88013,88015,87972,88703,88750,87944,88595,88154,87874,87783,87880,87873,88797,87782,88701,88748,88596,88594,92893,92894,93002,93003,93004,93005,93006,93007,93008,93009,93010,93011,93012,93013,93014,93015,93341,93342,93343,93344,93345,93346,93347,93348,93349,93350,93351,93352))"
          }
        },
        {
          "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": 15,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "76.50",
              "eval_cost": "1.53",
              "prefix_cost": "168.67",
              "data_read_per_join": "39K"
            },
            "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": 15,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "3.83",
              "eval_cost": "1.53",
              "prefix_cost": "174.03",
              "data_read_per_join": "244"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
87632 7210,7211,7214M 0
87637 7210,7211,7214M 0
87640 7210,7211,7214M 0
87781 7210,7211,7321M 0
87782 7210,7211,7321M 0
87783 7210,7211,7321M 0
87873 7241,7309,7346,7208M
87874 7241,7309,7346,7208M
87875 7241,7309,7346,7208M
87876 7241,7309,7346,7208M
87880 7241,7309,7346,7208M
87881 7241,7309,7346,7208M
87882 7241,7309,7346,7208M
87937 7345,7347,7259M
87938 7320,7260M
87941 7320,7260M
87942 7320,7260M
87944 7320,7260M
87945 7320,7260M
87948 7345,7347,7259M
87950 7345,7347,7259M
87952 7345,7347,7259M
87959 7320,7260M
87961 7320,7260M
87964 7320,7260M
87972 7320,7260M
87987 7345,7347,7259M
87988 7320,7260M
87990 7320,7260M
87997 7345,7347,7259M
87998 7320,7260M
88000 7320,7260M
88004 7345,7347,7259M
88006 7320,7260M
88013 7320,7260M
88015 7320,7260M
88018 7320,7260M
88021 7320,7260M
88026 7345,7347,7259M
88029 7345,7347,7259M
88031 7320,7260M
88047 7345,7347,7259M
88048 7345,7347,7259M
88050 7345,7347,7259M
88051 7345,7347,7259M
88052 7320,7260M
88053 7320,7260M
88054 7320,7260M
88154 7320,7260M
88506 7241,7309,7346,7208M
88507 7241,7309,7346,7208M
88510 7241,7309,7346,7208M
88561 7210,7211,7214M 0
88594 7210,7211,7282M 0
88595 7210,7211,7282M 0
88596 7210,7211,7282M 0
88701 7210,7211,7282M 0
88702 7210,7211,7282M 0
88703 7210,7211,7282M 0
88748 7210,7211,7282M 0
88749 7210,7211,7282M 0
88750 7210,7211,7282M 0
88797 7210,7211,7282M 0
88798 7210,7211,7282M 0
88799 7210,7211,7282M 0
90826 7241,7309,7346,7208M
90827 7241,7309,7346,7208M
90828 7241,7309,7346,7208M
92893 7241,7309,7346,7208M
92894 7241,7309,7346,7208M
93002 7241,7309,7346,7208M
93003 7241,7309,7346,7208M
93004 7241,7309,7346,7208M
93005 7241,7309,7346,7208M
93006 7241,7309,7346,7208M
93007 7241,7309,7346,7208M
93008 7241,7309,7346,7208M
93009 7241,7309,7346,7208M
93010 7241,7309,7346,7208M
93011 7241,7309,7346,7208M
93012 7241,7309,7346,7208M
93013 7241,7309,7346,7208M
93014 7241,7309,7346,7208M
93015 7241,7309,7346,7208M
93341 7241,7309,7346,7208M
93342 7241,7309,7346,7208M
93343 7241,7309,7346,7208M
93344 7241,7309,7346,7208M
93345 7241,7309,7346,7208M
93346 7241,7309,7346,7208M
93347 7241,7309,7346,7208M
93348 7241,7309,7346,7208M
93349 7241,7309,7346,7208M
93350 7241,7309,7346,7208M
93351 7241,7309,7346,7208M
93352 7241,7309,7346,7208M