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 = 278 
WHERE 
  cscart_products_categories.product_id IN (
    1291, 1287, 1283, 1279, 1277, 1275, 1271, 
    1267, 1264, 1262, 1258, 1256, 1254, 
    1250, 1248, 1246, 1245, 1131, 1130, 
    1129, 1128, 1127, 1126, 1125
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00235

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "33.93"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "4.31"
      },
      "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": 4,
            "filtered": "7.02",
            "index_condition": "(`wearethehelpful_scalesta_net`.`cscart_products_categories`.`product_id` in (1291,1287,1283,1279,1277,1275,1271,1267,1264,1262,1258,1256,1254,1250,1248,1246,1245,1131,1130,1129,1128,1127,1126,1125))",
            "cost_info": {
              "read_cost": "15.34",
              "eval_cost": "0.43",
              "prefix_cost": "28.11",
              "data_read_per_join": "68"
            },
            "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": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.08",
              "eval_cost": "0.43",
              "prefix_cost": "29.62",
              "data_read_per_join": "68"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
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
1129 266M,267,271,288,276,297,299,300,301,323,329
1130 266M,267,271,288,276,297,299,300,301,319,323,329
1131 266M,267,271,288,276,278,297,299,300,301,323,329 0
1245 288,276,278M,297,309,308,310 0
1246 288,276,278M,297,309,308,310 0
1248 278M,297,300,301,308,310 0
1250 278M,308,310 0
1254 278M,308,310 0
1256 278M,297,308,310 0
1258 288,276,278M,297,309,308,310 0
1262 288,276,278M,297,309,308,310 0
1264 288,276,278M,297,309,308,310 0
1267 288,276,278M,297,309,308,310 0
1271 288,276,278M,297,309,308,310 0
1275 288,276,278M,297,309,308,310 0
1277 278M,297,308,310 0
1279 278M,297,308,310 0
1283 278M,297,308,310 0
1287 278M,297,308,310 0
1291 278M,297,308,310 0