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 (
    220173, 339556, 254330, 339744, 339676, 
    339576, 339461, 391686, 339748, 392163, 
    387088, 339667, 339645, 151062, 339684, 
    151100, 254331, 339583, 387086, 339588, 
    339708, 387055, 339826, 339454, 339547, 
    339553, 339633, 387090, 339580, 339548, 
    339657, 339777, 339632, 339649, 339711, 
    339743, 339719, 339647, 339716, 339773, 
    339776, 387065, 339474, 339756, 339745, 
    339471, 387054, 265037, 339577, 339848, 
    339666, 339552, 339665, 339669, 339767, 
    339670, 387066, 339833, 339698, 339703, 
    220171, 339557, 339544, 339646, 339651, 
    339749, 339824, 339455, 339628, 339591, 
    387052, 339784, 339549, 339565, 339673, 
    339614, 339789, 339575, 339662, 265040, 
    339595, 339834, 339853, 339653, 339658, 
    339818, 339626, 339631, 339717, 339852, 
    339559, 339470, 339545, 339487, 339542, 
    339822, 339579, 339567, 271697, 339850
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00211

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "300.76"
    },
    "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": 107,
            "rows_produced_per_join": 107,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "22.57",
              "eval_cost": "21.40",
              "prefix_cost": "43.97",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (220173,339556,254330,339744,339676,339576,339461,391686,339748,392163,387088,339667,339645,151062,339684,151100,254331,339583,387086,339588,339708,387055,339826,339454,339547,339553,339633,387090,339580,339548,339657,339777,339632,339649,339711,339743,339719,339647,339716,339773,339776,387065,339474,339756,339745,339471,387054,265037,339577,339848,339666,339552,339665,339669,339767,339670,387066,339833,339698,339703,220171,339557,339544,339646,339651,339749,339824,339455,339628,339591,387052,339784,339549,339565,339673,339614,339789,339575,339662,265040,339595,339834,339853,339653,339658,339818,339626,339631,339717,339852,339559,339470,339545,339487,339542,339822,339579,339567,271697,339850))"
          }
        },
        {
          "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": 107,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "107.00",
              "eval_cost": "21.40",
              "prefix_cost": "172.37",
              "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": "107.00",
              "eval_cost": "1.07",
              "prefix_cost": "300.77",
              "data_read_per_join": "31K"
            },
            "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
151062 2404M
151100 2404M
220171 1690M
220173 1690M
254330 2623M
254331 2623M
265037 1907M
265040 1907M
271697 2386M
339454 9940M
339455 9940M
339461 9940M
339470 9940M
339471 9940M
339474 9940M
339487 9940M
339542 9940M
339544 9940M
339545 9940M
339547 9940M
339548 9940M
339549 9940M
339552 395M
339553 395M
339556 395M
339557 395M
339559 395M
339565 395M
339567 395M
339575 9941M
339576 395M
339577 395M
339579 395M
339580 395M
339583 395M
339588 9941M
339591 395M
339595 395M
339614 395M
339626 395M
339628 395M
339631 395M
339632 395M
339633 395M
339645 395M
339646 395M
339647 395M
339649 395M
339651 395M
339653 395M
339657 395M
339658 395M
339662 395M
339665 395M
339666 395M
339667 395M
339669 395M
339670 395M
339673 395M
339676 395M
339684 9941M
339698 9940M
339703 395M
339708 9941M
339711 395M
339716 395M
339717 395M
339719 395M
339743 395M
339744 395M
339745 395M
339748 395M
339749 395M
339756 395M
339767 395M
339773 395M
339776 9941M
339777 9941M
339784 9943M
339789 9943M
339818 395M
339822 395M
339824 395M
339826 395M
339833 395M
339834 395M
339848 395M
339850 395M
339852 395M
339853 395M
387052 1518M
387054 10425,10426M
387055 1505M
387065 1505,3028M
387066 1505,10411M
387086 10425,10426,1518M
387088 1505,10426,1518M
387090 10425M
391686 394M
392163 2577M