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 (
    381712, 339825, 430703, 430845, 431042, 
    431200, 430885, 381711, 430865, 430976, 
    431316, 430887, 430904, 430936, 430992, 
    431238, 431251, 431393, 339855, 430661, 
    430753, 430756, 430836, 431003, 431046, 
    431061, 430801, 430810, 430866, 430939, 
    431011, 431029, 431072, 431171, 431193, 
    431333, 430932, 430788, 430809, 430999, 
    431052, 431192, 431205, 430905, 430910, 
    430927, 430749, 430862, 431062, 431463, 
    339726, 430634, 430794, 430870, 431039, 
    431091, 431314, 431024, 431315, 431327, 
    430677, 430704, 430714, 430853, 430888, 
    430923, 431098, 431242, 430687, 431028, 
    430641, 430675, 430707, 430713, 430851, 
    430895, 431112, 431326, 431339, 430694, 
    430708, 430738, 430782, 430811, 430827, 
    430861, 430874, 430937, 431077, 431308, 
    431365, 339838, 431245, 339841, 430855, 
    431054, 430800, 430852, 430863, 431129
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00204

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "281.15"
    },
    "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": 100,
            "rows_produced_per_join": 100,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "21.15",
              "eval_cost": "20.00",
              "prefix_cost": "41.15",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (381712,339825,430703,430845,431042,431200,430885,381711,430865,430976,431316,430887,430904,430936,430992,431238,431251,431393,339855,430661,430753,430756,430836,431003,431046,431061,430801,430810,430866,430939,431011,431029,431072,431171,431193,431333,430932,430788,430809,430999,431052,431192,431205,430905,430910,430927,430749,430862,431062,431463,339726,430634,430794,430870,431039,431091,431314,431024,431315,431327,430677,430704,430714,430853,430888,430923,431098,431242,430687,431028,430641,430675,430707,430713,430851,430895,431112,431326,431339,430694,430708,430738,430782,430811,430827,430861,430874,430937,431077,431308,431365,339838,431245,339841,430855,431054,430800,430852,430863,431129))"
          }
        },
        {
          "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": 100,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "20.00",
              "prefix_cost": "161.15",
              "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": "100.00",
              "eval_cost": "1.00",
              "prefix_cost": "281.15",
              "data_read_per_join": "29K"
            },
            "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
339726 395M
339825 395M
339838 395M
339841 395M
339855 395M
381711 2578M
381712 2578M
430634 2601M
430641 2601M
430661 2601M
430675 2601M
430677 2601M
430687 2601M
430694 2601M
430703 2601M
430704 2601M
430707 2601M
430708 2601M
430713 2601M
430714 2601M
430738 2601M
430749 2601M
430753 2601M
430756 2601M
430782 2601M
430788 2601M
430794 2601M
430800 2601M
430801 2601M
430809 2601M
430810 2601M
430811 2601M
430827 2601M
430836 2601M
430845 2601M
430851 2601M
430852 2601M
430853 2601M
430855 2601M
430861 2601M
430862 2601M
430863 2601M
430865 2601M
430866 2601M
430870 2601M
430874 2601M
430885 2601M
430887 2601M
430888 2601M
430895 2601M
430904 2601M
430905 2601M
430910 2601M
430923 2601M
430927 2601M
430932 2601M
430936 2601M
430937 2601M
430939 2601M
430976 2601M
430992 2601M
430999 2601M
431003 2601M
431011 2601M
431024 2601M
431028 2601M
431029 2601M
431039 2601M
431042 2601M
431046 2601M
431052 2601M
431054 2601M
431061 2601M
431062 2601M
431072 2601M
431077 2601M
431091 2601M
431098 2601M
431112 2601M
431129 2601M
431171 2601M
431192 2601M
431193 2601M
431200 2601M
431205 2601M
431238 2601M
431242 2601M
431245 2601M
431251 2601M
431308 2601M
431314 2601M
431315 2601M
431316 2601M
431326 2601M
431327 2601M
431333 2601M
431339 2601M
431365 2601M
431393 2601M
431463 2601M