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 (
    339769, 430915, 431100, 430803, 339750, 
    339829, 430747, 430748, 430916, 430924, 
    431195, 431203, 339695, 339714, 339735, 
    431176, 431196, 431204, 381701, 430648, 
    431133, 431158, 339807, 430636, 381702, 
    430823, 431199, 339752, 339746, 381687, 
    430848, 430903, 431122, 430831, 387047, 
    431139, 339452, 339654, 339479, 339755, 
    431150, 339847, 339656, 430665, 339712, 
    431145, 430696, 431102, 430771, 430907, 
    430649, 339851, 430912, 430638, 430646, 
    430647, 339715, 430935, 339648, 339668, 
    339485, 339729, 381696, 431097, 339671, 
    339681, 339655, 431151, 339760, 431201, 
    430766, 430821, 339664, 339694, 430824, 
    431068, 431359, 339828, 339809, 430857, 
    339812, 339817, 430746, 430813, 339761, 
    339650, 339697, 430925, 431103, 431163, 
    339720, 431085, 431164, 430817, 430902, 
    339835, 430654, 431313, 431053, 431120
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00328

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 (339769,430915,431100,430803,339750,339829,430747,430748,430916,430924,431195,431203,339695,339714,339735,431176,431196,431204,381701,430648,431133,431158,339807,430636,381702,430823,431199,339752,339746,381687,430848,430903,431122,430831,387047,431139,339452,339654,339479,339755,431150,339847,339656,430665,339712,431145,430696,431102,430771,430907,430649,339851,430912,430638,430646,430647,339715,430935,339648,339668,339485,339729,381696,431097,339671,339681,339655,431151,339760,431201,430766,430821,339664,339694,430824,431068,431359,339828,339809,430857,339812,339817,430746,430813,339761,339650,339697,430925,431103,431163,339720,431085,431164,430817,430902,339835,430654,431313,431053,431120))"
          }
        },
        {
          "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
339452 9940M
339479 9940M
339485 9940M
339648 395M
339650 395M
339654 395M
339655 395M
339656 395M
339664 395M
339668 395M
339671 395M
339681 9943M
339694 395M
339695 395M
339697 395M
339712 395M
339714 395M
339715 395M
339720 395M
339729 9940M
339735 395M
339746 395M
339750 395M
339752 395M
339755 395M
339760 395M
339761 395M
339769 395M
339807 9940M
339809 9940M
339812 9940M
339817 395M
339828 395M
339829 395M
339835 395M
339847 395M
339851 395M
381687 10409M
381696 10411M
381701 10410M
381702 10410M
387047 2578M
430636 2601M
430638 2601M
430646 2601M
430647 2601M
430648 2601M
430649 2601M
430654 2601M
430665 2601M
430696 2601M
430746 2601M
430747 2601M
430748 2601M
430766 2601M
430771 2601M
430803 2601M
430813 2601M
430817 2601M
430821 2601M
430823 2601M
430824 2601M
430831 2601M
430848 2601M
430857 2601M
430902 2601M
430903 2601M
430907 2601M
430912 2601M
430915 2601M
430916 2601M
430924 2601M
430925 2601M
430935 2601M
431053 2601M
431068 2601M
431085 2601M
431097 2601M
431100 2601M
431102 2601M
431103 2601M
431120 2601M
431122 2601M
431133 2601M
431139 2601M
431145 2601M
431150 2601M
431151 2601M
431158 2601M
431163 2601M
431164 2601M
431176 2601M
431195 2601M
431196 2601M
431199 2601M
431201 2601M
431203 2601M
431204 2601M
431313 2601M
431359 2601M