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 (
    13452, 13454, 13456, 13457, 13458, 13459, 
    13480, 13482, 13484, 13485, 13486, 
    13487, 13866, 13867, 13868, 13869, 
    13873, 13874, 13875, 13951, 13952, 
    13953, 13954, 13955, 13956, 13957, 
    13958, 13959, 13960, 13961, 13962, 
    13969, 13970, 13974, 13975, 13976, 
    13977, 13978, 13979, 13980, 13981, 
    13982, 13983, 13984, 13985, 13986, 
    13987, 13988, 14021, 14022, 15747, 
    15748, 15753, 15754, 15755, 15756, 
    16340, 16344, 16345, 16351, 16352, 
    16353
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00081

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.276354807,
    "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": 130,
          "cost": 0.07275521,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (13452,13454,13456,13457,13458,13459,13480,13482,13484,13485,13486,13487,13866,13867,13868,13869,13873,13874,13875,13951,13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13969,13970,13974,13975,13976,13977,13978,13979,13980,13981,13982,13983,13984,13985,13986,13987,13988,14021,14022,15747,15748,15753,15754,15755,15756,16340,16344,16345,16351,16352,16353)",
          "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": 130,
          "rows": 1,
          "cost": 0.119554,
          "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
13452 1632M
13454 1632M
13456 1632M
13457 1632M
13458 1632M
13459 1632M
13480 1632M
13482 1632M
13484 1632M
13485 1632M
13486 1632M
13487 1632M
13866 574M
13867 574M
13868 574M
13869 574M
13873 574M
13874 574M
13875 574M
13951 576M
13952 576M
13953 576M
13954 576M
13955 576M
13956 576M
13957 576M
13958 576M
13959 576M
13960 576M
13961 576M
13962 576M
13969 576M
13970 576M
13974 576M
13975 576M
13976 576M
13977 576M
13978 576M
13979 576M
13980 576M
13981 576M
13982 576M
13983 576M
13984 576M
13985 576M
13986 576M
13987 576M
13988 576M
14021 578M
14022 578M
15747 1397,1401,1613,1614,1620,1671,1617M
15748 1397,1401,1613,1614,1620,1671,1617M
15753 1397,1613,1614,1620,1671,1617M
15754 1397,1613,1614,1620,1671,1617M
15755 1397,1613,1614,1620,1671,1617M
15756 1397,1613,1614,1620,1671,1617M
16340 925,1125,1397,1613,1620,1670,1671,1396M
16344 925,1125,1397,1613,1620,1670,1671,1396M
16345 925,1125,1397,1613,1620,1670,1671,1396M
16351 1397,1613,1614,1620,1671,1617M
16352 1397,1613,1614,1620,1671,1617M
16353 1397,1613,1614,1620,1671,1617M