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 (
    15167, 16346, 16334, 16348, 15749, 14660, 
    14149, 14650, 16347, 15166, 15732, 
    14651, 14140, 14656, 14654, 14661, 
    15751, 16338, 15108, 15753, 16354, 
    14136, 16340, 15747
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00107

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.231408414,
    "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": 122,
          "cost": 0.04016637,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (15167,16346,16334,16348,15749,14660,14149,14650,16347,15166,15732,14651,14140,14656,14654,14661,15751,16338,15108,15753,16354,14136,16340,15747)",
          "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": 122,
          "rows": 1,
          "cost": 0.11239848,
          "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
14136 925,1393,1395,1406M
14140 925,1125,1393,1395M
14149 925,1125,1614,1396M
14650 1613,1614M
14651 1613,1614M
14654 925,1125,1405,1672,1393M
14656 925,1125,1393,1613,1672M
14660 1125,1395,1396,1613,1670,925M
14661 925,1125,1393,1395,1613,1672M
15108 1623,1680,1683,1614M
15166 1614,1617,1680,1683,1623M
15167 1614,1617,1623,1627,1683,1680M
15732 1614,1623,1680,1617M
15747 1397,1401,1613,1614,1620,1671,1617M
15749 1397,1401,1613,1614,1620,1671,1617M
15751 925,1396,1398,1411,1613M
15753 1397,1613,1614,1620,1671,1617M
16334 925,1125,1670,1396M
16338 925,1125,1397,1613,1620,1670,1671,1396M
16340 925,1125,1397,1613,1620,1670,1671,1396M
16346 1397,1613,1614,1620,1671,1617M
16347 1397,1613,1614,1620,1671,1617M
16348 1397,1613,1614,1620,1671,1617M
16354 1614,1617M