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 (
    431129, 435509, 430656, 430863, 431338, 
    431423, 430856, 430993, 431051, 431074, 
    431165, 339782, 430688, 430702, 430722, 
    430723, 430778, 430816, 430984, 431247, 
    339718, 339675, 431005, 431027, 430627, 
    430742, 430805, 431007, 431022, 431184, 
    339604, 430720, 430839, 430878, 430933, 
    430994, 431177, 430826, 430991, 431019, 
    431357, 430917, 430990, 431108, 431264, 
    431275, 431426, 430872, 430889, 430897, 
    430918, 430940, 431297, 431345, 430690, 
    430791, 430840, 431220, 431501, 430652, 
    430790, 430835, 430958, 430968, 430977, 
    430979, 431342, 430674, 430804, 430828, 
    430886, 430960, 431138, 431358, 430786, 
    430871, 430969, 430931, 430952, 430972, 
    431006, 431428, 431451, 431467, 339597, 
    430780, 431288, 431336, 431395, 430692, 
    430715, 430770, 430894, 430953, 431503, 
    339846, 387050, 430666, 430726, 431037
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00242

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 (431129,435509,430656,430863,431338,431423,430856,430993,431051,431074,431165,339782,430688,430702,430722,430723,430778,430816,430984,431247,339718,339675,431005,431027,430627,430742,430805,431007,431022,431184,339604,430720,430839,430878,430933,430994,431177,430826,430991,431019,431357,430917,430990,431108,431264,431275,431426,430872,430889,430897,430918,430940,431297,431345,430690,430791,430840,431220,431501,430652,430790,430835,430958,430968,430977,430979,431342,430674,430804,430828,430886,430960,431138,431358,430786,430871,430969,430931,430952,430972,431006,431428,431451,431467,339597,430780,431288,431336,431395,430692,430715,430770,430894,430953,431503,339846,387050,430666,430726,431037))"
          }
        },
        {
          "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
339597 395M
339604 395M
339675 395M
339718 395M
339782 395M
339846 395M
387050 2578M
430627 2601M
430652 2601M
430656 2601M
430666 2601M
430674 2601M
430688 2601M
430690 2601M
430692 2601M
430702 2601M
430715 2601M
430720 2601M
430722 2601M
430723 2601M
430726 2601M
430742 2601M
430770 2601M
430778 2601M
430780 2601M
430786 2601M
430790 2601M
430791 2601M
430804 2601M
430805 2601M
430816 2601M
430826 2601M
430828 2601M
430835 2601M
430839 2601M
430840 2601M
430856 2601M
430863 2601M
430871 2601M
430872 2601M
430878 2601M
430886 2601M
430889 2601M
430894 2601M
430897 2601M
430917 2601M
430918 2601M
430931 2601M
430933 2601M
430940 2601M
430952 2601M
430953 2601M
430958 2601M
430960 2601M
430968 2601M
430969 2601M
430972 2601M
430977 2601M
430979 2601M
430984 2601M
430990 2601M
430991 2601M
430993 2601M
430994 2601M
431005 2601M
431006 2601M
431007 2601M
431019 2601M
431022 2601M
431027 2601M
431037 2601M
431051 2601M
431074 2601M
431108 2601M
431129 2601M
431138 2601M
431165 2601M
431177 2601M
431184 2601M
431220 2601M
431247 2601M
431264 2601M
431275 2601M
431288 2601M
431297 2601M
431336 2601M
431338 2601M
431342 2601M
431345 2601M
431357 2601M
431358 2601M
431395 2601M
431423 2601M
431426 2601M
431428 2601M
431451 2601M
431467 2601M
431501 2601M
431503 2601M
435509 2601M