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 (
    339678, 220178, 431162, 431128, 339465, 
    339786, 339457, 431132, 339477, 431099, 
    431202, 339541, 339643, 265042, 339796, 
    391798, 392175, 339489, 430637, 430639, 
    431096, 339699, 339469, 339797, 392167, 
    339458, 339798, 339606, 339685, 339482, 
    431168, 431141, 339468, 339453, 431137, 
    431153, 431155, 431130, 431033, 339730, 
    430911, 339731, 430640, 381703, 431134, 
    339478, 431125, 431154, 431090, 339794, 
    431187, 431067, 431146, 339463, 431065, 
    339709, 431094, 431048, 339467, 430767, 
    430697, 431104, 339753, 431050, 339460, 
    381725, 430745, 431124, 431117, 339696, 
    339757, 339464, 339808, 339787, 339806, 
    339805, 392169, 431157, 431191, 339810, 
    431160, 339707, 339701, 339704, 430850, 
    430681, 430743, 431084, 431116, 430908, 
    431107, 392166, 339677, 430998, 339769, 
    339814, 339750, 339758, 430655, 430744
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00342

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 (339678,220178,431162,431128,339465,339786,339457,431132,339477,431099,431202,339541,339643,265042,339796,391798,392175,339489,430637,430639,431096,339699,339469,339797,392167,339458,339798,339606,339685,339482,431168,431141,339468,339453,431137,431153,431155,431130,431033,339730,430911,339731,430640,381703,431134,339478,431125,431154,431090,339794,431187,431067,431146,339463,431065,339709,431094,431048,339467,430767,430697,431104,339753,431050,339460,381725,430745,431124,431117,339696,339757,339464,339808,339787,339806,339805,392169,431157,431191,339810,431160,339707,339701,339704,430850,430681,430743,431084,431116,430908,431107,392166,339677,430998,339769,339814,339750,339758,430655,430744))"
          }
        },
        {
          "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
220178 1690M
265042 1907M
339453 9940M
339457 9940M
339458 9940M
339460 9940M
339463 9940M
339464 9940M
339465 9940M
339467 9940M
339468 9940M
339469 9940M
339477 9940M
339478 9940M
339482 9940M
339489 9940M
339541 9940M
339606 395M
339643 395M
339677 395M
339678 9940M
339685 9940M
339696 395M
339699 9940M
339701 9940M
339704 395M
339707 395M
339709 9940M
339730 9940M
339731 9940M
339750 395M
339753 395M
339757 395M
339758 395M
339769 395M
339786 9943M
339787 9943M
339794 9943M
339796 9943M
339797 9943M
339798 9943M
339805 9943M
339806 9940M
339808 9940M
339810 9940M
339814 395M
381703 10410M
381725 2599M
391798 266M 0
392166 2577M
392167 2577M
392169 2577M
392175 2577M
430637 2601M
430639 2601M
430640 2601M
430655 2601M
430681 2601M
430697 2601M
430743 2601M
430744 2601M
430745 2601M
430767 2601M
430850 2601M
430908 2601M
430911 2601M
430998 2601M
431033 2601M
431048 2601M
431050 2601M
431065 2601M
431067 2601M
431084 2601M
431090 2601M
431094 2601M
431096 2601M
431099 2601M
431104 2601M
431107 2601M
431116 2601M
431117 2601M
431124 2601M
431125 2601M
431128 2601M
431130 2601M
431132 2601M
431134 2601M
431137 2601M
431141 2601M
431146 2601M
431153 2601M
431154 2601M
431155 2601M
431157 2601M
431160 2601M
431162 2601M
431168 2601M
431187 2601M
431191 2601M
431202 2601M