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 (
    10768, 10767, 10766, 10765, 10764, 10763, 
    10762, 10761, 10760, 10759, 10758, 
    10757, 10756, 10755, 10754, 10753, 
    10752, 10751, 10750, 10749, 10748, 
    10747, 15736, 15737, 15738, 15739, 
    15740, 15741, 15742, 15743, 15745, 
    15746, 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.00159

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": 160,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (10768,10767,10766,10765,10764,10763,10762,10761,10760,10759,10758,10757,10756,10755,10754,10753,10752,10751,10750,10749,10748,10747,15736,15737,15738,15739,15740,15741,15742,15743,15745,15746,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
10747 1677M
10748 1677M
10749 1677M
10750 1677M
10751 1677M
10752 1677M
10753 1680M
10754 1680M
10755 1680M
10756 1679M
10757 1679M
10758 1679M
10759 1678M
10760 1678M
10761 1678M
10762 1678M
10763 1678M
10764 1678M
10765 1678M
10766 1678M
10767 1681M
10768 1681M
12574 277,267,278M
12632 277,278,267M
12633 277,278,267M
12703 1666M
15736 301,1673M
15737 301,1673M
15738 301,1673M
15739 1673,301M
15740 301,1673M
15741 301,1673M
15742 1673,301M
15743 301,1673M
15744 301,1673M
15745 301,1673M
15746 301,1673M
15938 277,267M
15965 272M
15966 272M
15968 272M