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 (
    13883, 13884, 13885, 13886, 13887, 13888, 
    13906, 13907, 13917, 13918, 13926, 
    13927, 13933, 13934, 13935, 13936, 
    13937, 13941, 13942, 13998, 13999, 
    14000, 14001, 14002, 14003, 14004, 
    14005, 14006, 14007, 14008, 14009, 
    14010
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00052

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.085975997,
    "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": 32,
          "cost": 0.03357848,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (13883,13884,13885,13886,13887,13888,13906,13907,13917,13918,13926,13927,13933,13934,13935,13936,13937,13941,13942,13998,13999,14000,14001,14002,14003,14004,14005,14006,14007,14008,14009,14010)",
          "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": 32,
          "rows": 1,
          "cost": 0.03189888,
          "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
13883 574M
13884 574M
13885 574M
13886 574M
13887 574M
13888 574M
13906 575M
13907 575M
13917 575M
13918 575M
13926 575M
13927 575M
13933 575M
13934 575M
13935 575M
13936 575M
13937 575M
13941 577M
13942 577M
13998 576M
13999 576M
14000 576M
14001 576M
14002 576M
14003 576M
14004 576M
14005 576M
14006 576M
14007 576M
14008 576M
14009 576M
14010 576M