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 (
    9975, 9976, 9977, 9978, 9979, 9876, 9877, 
    9878, 9880, 9881, 9882, 9883, 9885, 
    9886, 9888, 9889, 9890, 9891, 9892, 
    9893, 9894, 9895, 9896, 9897, 9899, 
    9900, 9901, 9903, 9838, 9839, 9840, 
    9841, 9842, 9843, 9844, 9845, 9846, 
    9847, 9848, 9849, 9850, 9851, 9852, 
    9853, 9854, 9855, 9856, 9857, 9858, 
    9859, 9860, 9861, 9862, 9863, 9814, 
    9815, 9816, 9817, 9818, 9820, 9821, 
    9822, 9823, 9824
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00630

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": 64,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (9975,9976,9977,9978,9979,9876,9877,9878,9880,9881,9882,9883,9885,9886,9888,9889,9890,9891,9892,9893,9894,9895,9896,9897,9899,9900,9901,9903,9838,9839,9840,9841,9842,9843,9844,9845,9846,9847,9848,9849,9850,9851,9852,9853,9854,9855,9856,9857,9858,9859,9860,9861,9862,9863,9814,9815,9816,9817,9818,9820,9821,9822,9823,9824)"
    },
    "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
9814 1622M
9815 1622M
9816 1622M
9817 1622M
9818 1622M
9820 1622M
9821 1622M
9822 1622M
9823 1622M
9824 1622M
9838 323M
9839 323M
9840 323M
9841 323M
9842 323M
9843 323M
9844 323M
9845 323M
9846 323M
9847 323M
9848 323M
9849 323M
9850 323M
9851 323M
9852 323M
9853 323M
9854 323M
9855 323M
9856 323M
9857 323M
9858 323M
9859 323M
9860 323M
9861 323M
9862 323M
9863 323M
9876 327M
9877 327M
9878 327M
9880 327M
9881 327M
9882 327M
9883 327M
9885 327M
9886 327M
9888 327M
9889 327M
9890 327M
9891 327M
9892 327M
9893 327M
9894 327M
9895 327M
9896 327M
9897 327M
9899 327M
9900 327M
9901 327M
9903 327M
9975 1641M
9976 1641M
9977 1641M
9978 1641M
9979 1641M