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 (
    13464, 13492, 13465, 13493, 13933, 13934, 
    13935, 13998, 13999, 14000, 14005, 
    14006, 14007, 14131, 14132, 14133, 
    14134, 14135, 14138, 14139, 15734, 
    15735, 15736, 15737, 15738, 15739, 
    15740, 19930, 19931
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00063

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.176369915,
    "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": 87,
          "cost": 0.039165995,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (13464,13492,13465,13493,13933,13934,13935,13998,13999,14000,14005,14006,14007,14131,14132,14133,14134,14135,14138,14139,15734,15735,15736,15737,15738,15739,15740,19930,19931)",
          "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": 87,
          "rows": 1,
          "cost": 0.08109308,
          "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
13464 1632M
13465 1632M
13492 1632M
13493 1632M
13933 575M
13934 575M
13935 575M
13998 576M
13999 576M
14000 576M
14005 576M
14006 576M
14007 576M
14131 1395,1406,1669,1393M
14132 1395,1406,1669,1393M
14133 644,1393,1395,1406M
14134 644,1393,1395,1406M
14135 644,1393,1395,1406M
14138 925,1125,1393,1395M
14139 925,1125,1393,1395M
15734 215,1397,1613,1614,1620,1671M
15735 215,1397,1613,1614,1620,1671M
15736 215,1397,1613,1614,1620,1671M
15737 215,1397,1613,1614,1620,1671M
15738 215,1397,1613,1614,1620,1671M
15739 215,1397,1613,1614,1620,1671M
15740 215,1397,1613,1614,1620,1671M
19930 1726,1614M
19931 1726,1614M