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 (
    15744, 12632, 12633, 10179, 10180, 10523, 
    10073, 10077, 10076, 10086, 10085, 
    10084, 10083, 10082, 10081, 10080, 
    10079, 10584, 10594, 12574, 10168, 
    10167, 12703, 15968, 15938, 10053, 
    10041, 9904, 9905, 15966, 15965, 9940
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00467

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": 58,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (15744,12632,12633,10179,10180,10523,10073,10077,10076,10086,10085,10084,10083,10082,10081,10080,10079,10584,10594,12574,10168,10167,12703,15968,15938,10053,10041,9904,9905,15966,15965,9940)"
    },
    "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
9904 1666M
9905 1666M
9940 275M
10041 1666M
10053 275M
10073 1674M
10076 1674M
10077 1674M
10079 1674M
10080 1674M
10081 1674M
10082 1674M
10083 1674M
10084 1674M
10085 1674M
10086 1674M
10167 1666M
10168 1666M
10179 1674M
10180 1674M
10523 1674M
10584 1674M
10594 1674M
12574 277,267,278M
12632 277,278,267M
12633 277,278,267M
12703 1666M
15744 301,1673M
15938 277,267M
15965 272M
15966 272M
15968 272M