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 = 267 
WHERE 
  cscart_products_categories.product_id IN (
    1909, 1136, 1135, 1134, 1133, 1132, 1131, 
    1130, 1129, 1128, 1127, 1126, 1125, 
    1124, 1123, 1111, 1110, 1109, 1108, 
    1107, 1102, 1101, 1099, 1096, 1094, 
    1092, 1088, 1054, 1053, 1051, 1050, 
    1049, 1048, 967, 966, 965, 964, 963, 
    962, 960, 959, 958, 957, 956, 955, 954, 
    953, 952, 951, 950, 949, 948, 947, 946, 
    945, 944, 943, 942, 941, 940, 939, 938, 
    937, 936, 935, 932, 931, 930, 929, 928, 
    927, 919, 918, 917, 517, 516, 515, 478, 
    477, 476, 475, 474, 464, 460, 434, 433, 
    432, 431, 428, 427, 424, 423, 422, 421, 
    420, 419
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00501

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "63.34"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "26.10"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 59,
            "rows_produced_per_join": 2,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "6.40",
              "eval_cost": "0.24",
              "prefix_cost": "6.64",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`wearethehelpful_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`wearethehelpful_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`wearethehelpful_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`wearethehelpful_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`wearethehelpful_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "wearethehelpful_scalesta_net.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 26,
            "rows_produced_per_join": 26,
            "filtered": "42.53",
            "index_condition": "(`wearethehelpful_scalesta_net`.`cscart_products_categories`.`product_id` in (1909,1136,1135,1134,1133,1132,1131,1130,1129,1128,1127,1126,1125,1124,1123,1111,1110,1109,1108,1107,1102,1101,1099,1096,1094,1092,1088,1054,1053,1051,1050,1049,1048,967,966,965,964,963,962,960,959,958,957,956,955,954,953,952,951,950,949,948,947,946,945,944,943,942,941,940,939,938,937,936,935,932,931,930,929,928,927,919,918,917,517,516,515,478,477,476,475,474,464,460,434,433,432,431,428,427,424,423,422,421,420,419))",
            "cost_info": {
              "read_cost": "15.34",
              "eval_cost": "2.61",
              "prefix_cost": "28.11",
              "data_read_per_join": "417"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "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",
              "wearethehelpful_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 26,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "6.52",
              "eval_cost": "2.61",
              "prefix_cost": "37.25",
              "data_read_per_join": "417"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
419 267,271M,288,294,276,278,297,299,300,319,323 0
420 267,271M,288,294,276,278,297,299,300,319,323 0
421 267,271M,288,294,276,278,297,299,300,319,323 0
422 266,267M,271,288,294,276,278,297,299,300,301,323 0
423 266M,267,271,288,294,276,278,297,299,300,301,323 0
424 266M,267,271,288,294,276,277,278,297,299,300,301,319,323 0
427 267,282,286,276M 0
428 267,282,286,276M 0
431 266M,267,271,288,276,277,278,297,299,300,301,319,323 0
432 266M,267,271,288,276,277,278,297,299,300,301,319,323 0
433 266M,267,271,288,276,277,278,297,299,300,301 0
434 266M,267,271,288,276,277,278,297,299,300,301,319,323 0
460 266,267M,271,297,299,300,301,305 0
464 266,267M,271,297,299,300,301,305 0
474 265,266,267,268,270M,282,297,303,318,325 0
475 265,266,267,268,270M,282,297,301,303,318,325 0
476 265,266,267,268,270M,282,297,301,303,318,325 0
477 265,266,267,268,270M,282,278,297,301,303,318,322,325 0
478 265,266,267,268,270M,282,278,297,301,303,317,318,322,325 0
515 265M,266,267,268,282,288,294,276,277,278,297,298,301,303,314,317,318,321,322,325 0
516 265M,266,267,268,282,288,294,276,297,298,301,303,314,325 0
517 265M,266,267,268,282,288,294,276,277,278,297,298,301,303,314,317,318,321,322,325 0
917 267M,271,288,294,276,297,300,309 0
918 267M,271,288,294,276,297,300 0
919 267M,271,288,294,276,297,300,309 0
927 265M,267,268,271,269,288,294,276,297,298,300,301,314 0
928 265M,267,268,271,269,288,294,276,297,298,300,301,314 0
929 265M,267,268,271,269,288,294,276,297,298,300,301,314 0
930 265M,266,267,268,271,269,277,278,297,298,300,301,317,322,325 0
931 265M,266,267,268,271,269,277,278,297,298,300,301,317,323,325 0
932 265M,266,267,268,271,269,277,278,297,298,300,317,322,325 0
935 266,267M,271,288,276,277,278,297,298,300,301,314,317,319,322,323 0
936 267,271M,288,276,297,298,300,314 0
937 267M,271,278,297,298,300 0
938 267,271,288,276M,297,298,300,314 0
939 267M,271,288,294,276,297,298,300,301,314 0
940 266,267M,271,288,294,276,297,298,300,301,309,314 0
941 266,267M,271,288,294,276,277,278,297,298,300,301,319,323 0
942 266,267,271,286,288,276M,297,300,302 0
943 266,267,271,286,288,276M,297,300,302 0
944 266,267M,271,278,297,300,302 0
945 266,267M,271,278,297,300,302 0
946 267,282,277,297,303 0
947 266,267M,271,296,297,299,300 0
948 266,267M,271,296,297,299,300 0
949 266,267M,271,296,297,299,300 0
950 266,267M,271,288,276,278,297,299,300,301,319,323 0
951 266,267M,271,288,276,278,297,299,300,301,319,323 0
952 266,267M,271,288,276,278,297,299,300,301,319,323 0
953 266,267M,271,288,276,278,297,299,300,301,319,323 0
954 266,267M,271,288,276,278,297,299,300,301,319,323 0
955 266,267M,271,288,276,278,297,299,300,301,319,323 0
956 266,267M,271,288,276,278,297,299,300,301,319,323 0
957 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
958 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
959 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
960 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
962 266M,267,271,278,297,299,300,301,323,329 0
963 266M,267,271,278,297,299,300,301,323,329 0
964 266M,267,271,278,297,299,300,301,323,329 0
965 266,267,282,286,276,297,301M,303,326 0
966 266,267,282,286,276,297,301M,303,326 0
967 266,267,282,286,295,276,277,278,297,301M,311,326 0
1048 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
1049 266,267M,271,288,294,276,278,297,299,300,301,323 0
1050 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
1051 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
1053 266,267M,271,288,294,276,277,278,297,299,300,301,319,323 0
1054 266M,286,295,276,277,278,297,301,311,326
1088 266M,286,295,276,277,278,297,301,311,326
1092 266M,267,282,286,276,297,301,326 0
1094 266M,286,295,276,277,278,297,301,311,326
1096 266M,297,301,326
1099 266M,286,295,276,277,278,297,301,311,326
1101 266M,286,276,278,297,301,311,326
1102 266M,297,301,326
1107 266,267,271,288,294,276,277,278,297M,299,300,301,319,323 0
1108 266,267,271,288,294,276,277,278,297M,299,300,301,319,323 0
1109 266,267,271,288,294,276,277,278,297M,299,300,301 0
1110 266,267,271,288,294,276,277,278,297M,299,300,301,319,323 0
1111 266,267,271,288,294,276,277,278,297M,299,300,301,319,323 0
1123 267,271,288,294,276,277,278,297M,300,319,323 0
1124 267,271,288,294,276,277,278,297M,300,319,323 0
1125 267,271,288,294,276,277,278,297M,300,319,323 0
1126 267,271,288,294,276,277,278,297M,300,319,323 0
1127 267,271,288,294,276,277,278,297M,300,309,319,323 0
1128 266M,267,271,288,276,297,299,300,301,323,329 0
1129 266M,267,271,288,276,297,299,300,301,323,329 0
1130 266M,267,271,288,276,297,299,300,301,319,323,329 0
1131 266M,267,271,288,276,278,297,299,300,301,323,329 0
1132 265,298,305M,325
1133 265,298,305M,325
1134 265,298,305M,325
1135 265,298,305M,325
1136 265,298,305M,325
1909 267,288,294M,276,314 0