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 (
    15168, 15169, 15734, 15735, 15736, 15737, 
    15738, 15739, 15740, 15747, 15748, 
    15753, 15754, 15755, 15756, 16338, 
    16339, 16340, 16344, 16345, 16348, 
    16349, 16350, 16351, 16352, 16353
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00102

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.304119953,
    "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": 164,
          "cost": 0.04798058,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (15168,15169,15734,15735,15736,15737,15738,15739,15740,15747,15748,15753,15754,15755,15756,16338,16339,16340,16344,16345,16348,16349,16350,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": 164,
          "rows": 1,
          "cost": 0.14996496,
          "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
15168 1614,1623,1680,1617M
15169 1614,1623,1680,1617M
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
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
16338 925,1125,1397,1613,1620,1670,1671,1396M
16339 925,1125,1397,1613,1620,1670,1671,1396M
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
16348 1397,1613,1614,1620,1671,1617M
16349 1397,1613,1614,1620,1671,1617M
16350 1397,1613,1614,1620,1671,1617M
16351 1397,1613,1614,1620,1671,1617M
16352 1397,1613,1614,1620,1671,1617M
16353 1397,1613,1614,1620,1671,1617M