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 (
    385, 125, 300, 2496, 1193, 309, 1876, 
    454, 332, 908, 1479, 1279, 299, 132, 
    1053, 2188, 295, 289, 1250, 993, 2512, 
    131, 1032, 495, 1251, 298, 934, 1452, 
    1196, 2420, 292, 303
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00099

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": 35,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (385,125,300,2496,1193,309,1876,454,332,908,1479,1279,299,132,1053,2188,295,289,1250,993,2512,131,1032,495,1251,298,934,1452,1196,2420,292,303)"
    },
    "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": ["dev.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
125 74M
131 115M
132 115M
289 50M
292 116M
295 137M
298 45M
299 45M
300 45M
303 81M
309 88M
332 35M
385 35M
454 44M
495 44M
908 136M
934 136M
993 80M
1032 80M
1053 80M
1193 72M
1196 72M
1250 46M
1251 48M
1279 62M
1452 136M
1479 136M
1876 44M
2188 44M
2420 44M
2496 57M
2512 44M