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 
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') 
WHERE 
  cscart_products_categories.product_id IN (
    10301, 10313, 10318, 10294, 10297, 10302, 
    10314, 10319, 12552, 12554, 10295, 
    10298, 10303, 10315, 10320, 10299, 
    10304, 10316, 10321, 10300, 10317, 
    10322, 12572, 12575, 12571, 12573, 
    10273, 10272, 10271, 10270, 10269, 
    10268
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00096

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 38,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (10301,10313,10318,10294,10297,10302,10314,10319,12552,12554,10295,10298,10303,10315,10320,10299,10304,10316,10321,10300,10317,10322,12572,12575,12571,12573,10273,10272,10271,10270,10269,10268)"
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["noframes_angrybeaver.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "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')"
    }
  }
}

Result

product_id category_ids
10268 323M
10269 323M
10270 323M
10271 323M
10272 323M
10273 323M
10294 775M
10295 775M
10297 1645M
10298 1645M
10299 1645M
10300 1645M
10301 1644M
10302 1644M
10303 1644M
10304 1644M
10313 1643M
10314 1643M
10315 1643M
10316 1643M
10317 1643M
10318 1643M
10319 1643M
10320 1643M
10321 1643M
10322 1643M
12552 267,270,268M
12554 267,270,268M
12571 267,278,277M
12572 267,277,278M
12573 267,278,277M
12575 267,278,277M