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 (
    13860, 13876, 13879, 14024, 13896, 13946, 
    13916, 13963, 13919, 13929, 13932, 
    13895, 14020, 13899, 13861, 13971, 
    13902, 13931, 13939, 13913, 14026, 
    13950, 13940, 13947
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00053

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.065879379,
    "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 (13860,13876,13879,14024,13896,13946,13916,13963,13919,13929,13932,13895,14020,13899,13861,13971,13902,13931,13939,13913,14026,13950,13940,13947)",
          "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
13860 574M
13861 574M
13876 574M
13879 574M
13895 574M
13896 574M
13899 574M
13902 575M
13913 575M
13916 575M
13919 575M
13929 575M
13931 575M
13932 575M
13939 575M
13940 577M
13946 577M
13947 577M
13950 577M
13963 576M
13971 576M
14020 578M
14024 578M
14026 578M