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 (
    14005, 15746, 16337, 16336, 15745, 14662, 
    13464, 13998, 13933, 14148, 14678, 
    14131, 13465, 18481, 19930, 19598, 
    19599, 19602, 14142, 14138, 14133, 
    14137, 13497, 15734
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00064

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.162097532,
    "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": 81,
          "cost": 0.034152285,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (14005,15746,16337,16336,15745,14662,13464,13998,13933,14148,14678,14131,13465,18481,19930,19598,19599,19602,14142,14138,14133,14137,13497,15734)",
          "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": 81,
          "rows": 1,
          "cost": 0.07572644,
          "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
13497 1633M
13933 575M
13998 576M
14005 576M
14131 1395,1406,1669,1393M
14133 644,1393,1395,1406M
14137 1393,1395,1406,925M
14138 925,1125,1393,1395M
14142 925,1125,1393,1406M
14148 925,1125,1126,1127,1402M
14662 646,925,1125,1395,1669,1396M
14678 1623,1680,1683,1614M
15734 215,1397,1613,1614,1620,1671M
15745 1397,1613,1614,1620,1671,1617M
15746 1397,1613,1614,1620,1671,1617M
16336 925,1125,1397,1613,1620,1670,1671,1396M
16337 925,1125,1397,1613,1620,1670,1671,1396M
18481 471M
19598 1716M
19599 1716M
19602 1716M
19930 1726,1614M