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 = 266 
WHERE 
  cscart_products_categories.product_id IN (
    391789, 265231, 81619, 285940, 81632, 
    271489, 81662, 339530, 265039, 265034, 
    285937, 271497, 387095, 81615, 392212, 
    285942, 339446, 271493, 81639, 271504, 
    265258, 81706, 265031, 339514, 264987, 
    265041, 265261, 265263, 339551, 271500, 
    339521, 286476, 81649, 264988, 285945, 
    271506, 265244, 265256, 271496, 271492, 
    339501, 151897, 339499, 285939, 339495, 
    339721, 366887, 392150, 81622, 392214, 
    392215, 265038, 81652, 271498, 81697, 
    339494, 265242, 339503, 339531, 224456, 
    81693, 339516, 285938, 81660, 271510, 
    359818, 285943, 271503, 339539, 285941, 
    339447, 339509, 81669, 271494, 264989, 
    285946, 264990, 271502, 265232, 265254, 
    339636, 285966, 285970, 114755, 339637, 
    339492, 285968, 339538, 369244, 271490, 
    339506, 265250, 265001, 265237, 271505, 
    339724, 392179, 339635, 81628, 339502
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00265

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "317.57"
    },
    "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": 113,
            "rows_produced_per_join": 113,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "23.77",
              "eval_cost": "22.60",
              "prefix_cost": "46.37",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (391789,265231,81619,285940,81632,271489,81662,339530,265039,265034,285937,271497,387095,81615,392212,285942,339446,271493,81639,271504,265258,81706,265031,339514,264987,265041,265261,265263,339551,271500,339521,286476,81649,264988,285945,271506,265244,265256,271496,271492,339501,151897,339499,285939,339495,339721,366887,392150,81622,392214,392215,265038,81652,271498,81697,339494,265242,339503,339531,224456,81693,339516,285938,81660,271510,359818,285943,271503,339539,285941,339447,339509,81669,271494,264989,285946,264990,271502,265232,265254,339636,285966,285970,114755,339637,339492,285968,339538,369244,271490,339506,265250,265001,265237,271505,339724,392179,339635,81628,339502))"
          }
        },
        {
          "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",
              "webmarco.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 113,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "113.00",
              "eval_cost": "22.60",
              "prefix_cost": "181.97",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "113.00",
              "eval_cost": "1.13",
              "prefix_cost": "317.57",
              "data_read_per_join": "33K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
81615 2404M
81619 2404M
81622 2404M
81628 2404M
81632 2404M
81639 2404M
81649 2404M
81652 2404M
81660 2404M
81662 2404M
81669 2404M
81693 2404M
81697 2404M
81706 2404M
114755 342M
151897 1907M
224456 2599M
264987 2374M
264988 2374M
264989 2374M
264990 2374M
265001 2374M
265031 2604M
265034 2604M
265038 1907M
265039 1907M
265041 1907M
265231 2604M
265232 2604M
265237 2604M
265242 2604M
265244 2604M
265250 2604M
265254 2604M
265256 2604M
265258 2604M
265261 2604M
265263 2604M
271489 2599M
271490 2599M
271492 2599M
271493 2599M
271494 2599M
271496 2599M
271497 2599M
271498 2599M
271500 2599M
271502 2599M
271503 2599M
271504 2599M
271505 2599M
271506 2599M
271510 2599M
285937 443,356M
285938 443,356M
285939 443,356M
285940 443,356M
285941 443,356M
285942 443,356M
285943 443,356M
285945 443,356M
285946 443,356M
285966 443,356M
285968 443,356M
285970 443,356M
286476 1516M
339446 9940M
339447 9940M
339492 9942M
339494 9942M
339495 9942M
339499 9942M
339501 9942M
339502 9942M
339503 9942M
339506 9942M
339509 9942M
339514 9942M
339516 9942M
339521 9942M
339530 9942M
339531 9942M
339538 9942M
339539 9942M
339551 9942M
339635 9942M
339636 9942M
339637 9942M
339721 9942M
339724 9942M
359818 266M 0
366887 2577M
369244 953M
387095 1505M
391789 443M
392150 2577M
392179 2577M
392212 443M
392214 443M
392215 443M