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 (
    309474, 309478, 206988, 391625, 309476, 
    391630, 309469, 391627, 391629, 262380, 
    309470, 252156, 206990, 206986, 309475, 
    309431, 391628, 206991, 309472, 252154, 
    391631, 339432, 265269, 206468, 339433, 
    262428, 308644, 206965, 13481, 13466, 
    339434, 339438, 262429, 206983, 308657, 
    206950, 262440, 262370, 262437, 206929, 
    308646, 339439, 230172, 259698, 13488, 
    206977, 339445, 13474, 262430, 252155, 
    262436, 262434, 262432, 13486, 339440, 
    206993, 262441, 173883, 13468, 262400, 
    230173, 339511, 339515, 206933, 339441, 
    13469, 254299, 13485, 252159, 13484, 
    254297, 252157, 427782, 253161, 262359, 
    225088, 262438, 253198, 262435, 253157, 
    262439, 81573, 81586, 225081, 225074, 
    35390, 254305, 159862, 38238, 13487, 
    225053, 262399, 262394, 252161, 225066, 
    262442, 252162, 287, 81610, 286682
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00298

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "334.38"
    },
    "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": 119,
            "rows_produced_per_join": 119,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "24.98",
              "eval_cost": "23.80",
              "prefix_cost": "48.78",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (309474,309478,206988,391625,309476,391630,309469,391627,391629,262380,309470,252156,206990,206986,309475,309431,391628,206991,309472,252154,391631,339432,265269,206468,339433,262428,308644,206965,13481,13466,339434,339438,262429,206983,308657,206950,262440,262370,262437,206929,308646,339439,230172,259698,13488,206977,339445,13474,262430,252155,262436,262434,262432,13486,339440,206993,262441,173883,13468,262400,230173,339511,339515,206933,339441,13469,254299,13485,252159,13484,254297,252157,427782,253161,262359,225088,262438,253198,262435,253157,262439,81573,81586,225081,225074,35390,254305,159862,38238,13487,225053,262399,262394,252161,225066,262442,252162,287,81610,286682))"
          }
        },
        {
          "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": 119,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "119.00",
              "eval_cost": "23.80",
              "prefix_cost": "191.58",
              "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": "119.00",
              "eval_cost": "1.19",
              "prefix_cost": "334.38",
              "data_read_per_join": "35K"
            },
            "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
287 267M
13466 267M
13468 267M
13469 267M
13474 267M
13481 267M
13484 267M
13485 267M
13486 267M
13487 267M
13488 267M
35390 267M
38238 267M
81573 266,6866M 0
81586 266,6866M 0
81610 2404M
159862 9290M
173883 1698M
206468 991M
206929 991M
206933 991M
206950 991M
206965 991M
206977 991M
206983 991M
206986 991M
206988 991M
206990 990M
206991 991M
206993 991M
225053 2578M
225066 2578M
225074 2578M
225081 2578M
225088 2578M
230172 2578M
230173 2578M
252154 994M
252155 994M
252156 994M
252157 994M
252159 2180M
252161 9849M
252162 2180M
253157 1913M
253161 1911M
253198 2374M
254297 1910M
254299 1910M
254305 1909M
259698 2578M
262359 2578M
262370 2578M
262380 2578M
262394 2578M
262399 2578M
262400 2578M
262428 9921M
262429 9921M
262430 9921M
262432 9940M
262434 9921M
262435 9921M
262436 9921M
262437 9922M
262438 9922M
262439 9922M
262440 9941M
262441 9922M
262442 1909M
265269 443M
286682 443M
308644 10247M
308646 10247M
308657 10247M
309431 10247,9867M
309469 2398,2399,2401,2397M
309470 2398,2399,2401,2397M
309472 2398,2399,2401,2397M
309474 2402,2397M
309475 2402,2397M
309476 2402,2397M
309478 2398,2399,2401,2402,2397M
339432 9940M
339433 9940M
339434 9940M
339438 9940M
339439 9940M
339440 9940M
339441 9940M
339445 9940M
339511 9942M
339515 9942M
391625 2178M
391627 2178M
391628 2178M
391629 2178M
391630 2178M
391631 2178M
427782 1516M