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 (
    35929, 35931, 35930, 35925, 35923, 32703, 
    32706, 32704, 35917, 35916, 32678, 
    33081, 35928, 35927, 35921, 32679, 
    32687, 32681, 32683, 32696, 32685, 
    32707, 32691, 35912, 32690, 35919, 
    35920, 32695, 32700, 33102
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00693

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "rows": 30,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (35929,35931,35930,35925,35923,32703,32706,32704,35917,35916,32678,33081,35928,35927,35921,32679,32687,32681,32683,32696,32685,32707,32691,35912,32690,35919,35920,32695,32700,33102)"
        }
      },
      {
        "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_db.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
32678 144M
32679 144M
32681 144M
32683 143M
32685 142M
32687 144M
32690 144M
32691 142M
32695 142M
32696 317M
32700 142M
32703 317M
32704 317M
32706 317M
32707 142M
33081 144M
33102 144M
35912 142M
35916 317M
35917 317M
35919 317M
35920 317M
35921 317M
35923 144M
35925 144M
35927 144M
35928 144M
35929 152M
35930 152M
35931 152M