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 (
    4712, 4502, 4729, 4698, 4724, 4691, 46176, 
    4684, 4490, 4688, 4508, 4498, 4690, 
    4719, 4504, 4700, 4692, 4519, 4510, 
    4696, 4735, 4495, 4687, 4505, 4694, 
    4731, 4501, 4506, 4693, 4497
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00188

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 (4712,4502,4729,4698,4724,4691,46176,4684,4490,4688,4508,4498,4690,4719,4504,4700,4692,4519,4510,4696,4735,4495,4687,4505,4694,4731,4501,4506,4693,4497)"
        }
      },
      {
        "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
4490 199M
4495 199M
4497 199M
4498 199M
4501 199M
4502 199M
4504 199M
4505 199M
4506 199M
4508 199M
4510 199M
4519 199M
4684 197M
4687 197M
4688 197M
4690 197M
4691 197M
4692 197M
4693 197M
4694 197M
4696 197M
4698 197M
4700 197M
4712 195M
4719 195M
4724 195M
4729 195M
4731 195M
4735 199M
46176 197M