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 (
    431225, 431483, 431058, 431207, 431430, 
    431475, 431496, 431086, 431479, 430986, 
    431036, 431282, 431351, 431391, 431450, 
    431223, 431059, 431227, 431437, 430716, 
    431294, 431492, 430996, 431278, 431296, 
    431396, 431435, 431460, 435511, 431413, 
    430777, 431367, 431221, 431261, 431323, 
    431331, 431485, 431276, 431258, 431307, 
    431312, 431348, 431471, 431382, 431448, 
    431095, 431477, 431499, 381714, 431214, 
    431310, 431375, 431449, 431266, 431299, 
    430728, 431491, 431347, 431366, 431436, 
    431441, 431075, 431418, 431489, 430709, 
    431228, 431265, 431321, 431400, 431363, 
    431486, 431189, 430670, 431206, 431370, 
    431374, 431388, 387053, 430774, 430779, 
    431209, 431232, 431256, 431257, 431379, 
    387048, 430710, 431179, 431404, 431445, 
    430668, 431293, 431277, 431286, 431462, 
    431317, 431473, 431476, 431320, 431390
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00339

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 (431225,431483,431058,431207,431430,431475,431496,431086,431479,430986,431036,431282,431351,431391,431450,431223,431059,431227,431437,430716,431294,431492,430996,431278,431296,431396,431435,431460,435511,431413,430777,431367,431221,431261,431323,431331,431485,431276,431258,431307,431312,431348,431471,431382,431448,431095,431477,431499,381714,431214,431310,431375,431449,431266,431299,430728,431491,431347,431366,431436,431441,431075,431418,431489,430709,431228,431265,431321,431400,431363,431486,431189,430670,431206,431370,431374,431388,387053,430774,430779,431209,431232,431256,431257,431379,387048,430710,431179,431404,431445,430668,431293,431277,431286,431462,431317,431473,431476,431320,431390))"
          }
        },
        {
          "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
381714 2578M
387048 2578M
387053 2578M
430668 2601M
430670 2601M
430709 2601M
430710 2601M
430716 2601M
430728 2601M
430774 2601M
430777 2601M
430779 2601M
430986 2601M
430996 2601M
431036 2601M
431058 2601M
431059 2601M
431075 2601M
431086 2601M
431095 2601M
431179 2601M
431189 2601M
431206 2601M
431207 2601M
431209 2601M
431214 2601M
431221 2601M
431223 2601M
431225 2601M
431227 2601M
431228 2601M
431232 2601M
431256 2601M
431257 2601M
431258 2601M
431261 2601M
431265 2601M
431266 2601M
431276 2601M
431277 2601M
431278 2601M
431282 2601M
431286 2601M
431293 2601M
431294 2601M
431296 2601M
431299 2601M
431307 2601M
431310 2601M
431312 2601M
431317 2601M
431320 2601M
431321 2601M
431323 2601M
431331 2601M
431347 2601M
431348 2601M
431351 2601M
431363 2601M
431366 2601M
431367 2601M
431370 2601M
431374 2601M
431375 2601M
431379 2601M
431382 2601M
431388 2601M
431390 2601M
431391 2601M
431396 2601M
431400 2601M
431404 2601M
431413 2601M
431418 2601M
431430 2601M
431435 2601M
431436 2601M
431437 2601M
431441 2601M
431445 2601M
431448 2601M
431449 2601M
431450 2601M
431460 2601M
431462 2601M
431471 2601M
431473 2601M
431475 2601M
431476 2601M
431477 2601M
431479 2601M
431483 2601M
431485 2601M
431486 2601M
431489 2601M
431491 2601M
431492 2601M
431496 2601M
431499 2601M
435511 2601M