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 (
    10390, 10389, 10388, 10387, 10386, 10384, 
    10383, 10382, 12679, 12678, 12677, 
    12676, 12675, 12674, 12673, 15779, 
    12672, 12671, 12994, 12993, 12992, 
    12991, 12990, 12989, 12988, 12987, 
    12986, 12985, 10343, 10345, 10346, 
    10347
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00332

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 (10390,10389,10388,10387,10386,10384,10383,10382,12679,12678,12677,12676,12675,12674,12673,15779,12672,12671,12994,12993,12992,12991,12990,12989,12988,12987,12986,12985,10343,10345,10346,10347)"
    },
    "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
10343 1646M
10345 1646M
10346 1646M
10347 1646M
10382 1654M
10383 1654M
10384 1654M
10386 1650M
10387 1650M
10388 1650M
10389 1650M
10390 1650M
12671 784M
12672 784M
12673 784M
12674 784M
12675 784M
12676 784M
12677 784M
12678 784M
12679 784M
12985 1649M
12986 1649M
12987 1649M
12988 1649M
12989 1649M
12990 1649M
12991 1649M
12992 1649M
12993 1649M
12994 1649M
15779 784M