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 (
    13416, 13417, 13418, 13452, 13419, 13420, 
    13453, 13502, 13421, 13501, 13422, 
    13454, 13455, 13423, 13456, 13457, 
    13458, 13459, 13505, 13424, 13496, 
    13425, 13426, 13495
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00053

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.065895603,
    "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"],
          "loops": 1,
          "rows": 24,
          "cost": 0.02579124,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (13416,13417,13418,13452,13419,13420,13453,13502,13421,13501,13422,13454,13455,13423,13456,13457,13458,13459,13505,13424,13496,13425,13426,13495)",
          "using_index": true
        }
      },
      {
        "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": ["u508912950_dev_2025.cscart_products_categories.category_id"],
          "loops": 24,
          "rows": 1,
          "cost": 0.02474336,
          "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
13416 1631M
13417 1631M
13418 1631M
13419 1631M
13420 1631M
13421 1631M
13422 1631M
13423 1631M
13424 1631M
13425 1631M
13426 1631M
13452 1632M
13453 1632M
13454 1632M
13455 1632M
13456 1632M
13457 1632M
13458 1632M
13459 1632M
13495 1633M
13496 1633M
13501 1634M
13502 1634M
13505 1634M