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, 431132, 265042, 339796, 339541, 
    339477, 339457, 339700, 431202, 431162, 
    339811, 339489, 339458, 431128, 431099, 
    339623, 431155, 392172, 339453, 339797, 
    339606, 339798, 339699, 430639, 431141, 
    339643, 339469, 392167, 431130, 431168, 
    339482, 339685, 431153, 339730, 431154, 
    339731, 431137, 431096, 339463, 381703, 
    392175, 339709, 431124, 339460, 430637, 
    431125, 381725, 339478, 339468, 431094, 
    339467, 430745, 431146, 339810, 430911, 
    339753, 431134, 430640, 431048, 339696, 
    431033, 431187, 339806, 339805, 339757, 
    339794, 339701, 339808, 431191, 430697, 
    430767, 431067, 431117, 339464, 339787, 
    381701, 431157, 431104, 381687, 431090, 
    392166, 431107, 431116, 431204, 339452, 
    431196, 431065, 339752, 339814, 430744, 
    431084, 339695, 339750, 431203, 431176, 
    339656, 431100, 431199, 430655, 431160
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00279

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,431132,265042,339796,339541,339477,339457,339700,431202,431162,339811,339489,339458,431128,431099,339623,431155,392172,339453,339797,339606,339798,339699,430639,431141,339643,339469,392167,431130,431168,339482,339685,431153,339730,431154,339731,431137,431096,339463,381703,392175,339709,431124,339460,430637,431125,381725,339478,339468,431094,339467,430745,431146,339810,430911,339753,431134,430640,431048,339696,431033,431187,339806,339805,339757,339794,339701,339808,431191,430697,430767,431067,431117,339464,339787,381701,431157,431104,381687,431090,392166,431107,431116,431204,339452,431196,431065,339752,339814,430744,431084,339695,339750,431203,431176,339656,431100,431199,430655,431160))"
          }
        },
        {
          "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
265042 1907M
339452 9940M
339453 9940M
339457 9940M
339458 9940M
339460 9940M
339463 9940M
339464 9940M
339467 9940M
339468 9940M
339469 9940M
339477 9940M
339478 9940M
339482 9940M
339489 9940M
339541 9940M
339606 395M
339623 395M
339643 395M
339656 395M
339678 9940M
339685 9940M
339695 395M
339696 395M
339699 9940M
339700 9940M
339701 9940M
339709 9940M
339730 9940M
339731 9940M
339750 395M
339752 395M
339753 395M
339757 395M
339787 9943M
339794 9943M
339796 9943M
339797 9943M
339798 9943M
339805 9943M
339806 9940M
339808 9940M
339810 9940M
339811 9940M
339814 395M
381687 10409M
381701 10410M
381703 10410M
381725 2599M
392166 2577M
392167 2577M
392172 2577M
392175 2577M
430637 2601M
430639 2601M
430640 2601M
430655 2601M
430697 2601M
430744 2601M
430745 2601M
430767 2601M
430911 2601M
431033 2601M
431048 2601M
431065 2601M
431067 2601M
431084 2601M
431090 2601M
431094 2601M
431096 2601M
431099 2601M
431100 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
431176 2601M
431187 2601M
431191 2601M
431196 2601M
431199 2601M
431202 2601M
431203 2601M
431204 2601M