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 (
    13439, 13440, 13441, 13442, 13443, 13444, 
    13445, 13446, 13447, 13448, 13449, 
    13450, 13451, 13452, 13453, 13454, 
    13455, 13456, 13457, 13458, 13459, 
    13460, 13461, 13462, 13467, 13468, 
    13469, 13470, 13471, 13472, 13473, 
    13474, 13475, 13476, 13477, 13478, 
    13479, 13480, 13481, 13482, 13483, 
    13484, 13485, 13486, 13487, 13488, 
    13489, 13490
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00085

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.126210922,
    "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": 48,
          "cost": 0.04915296,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (13439,13440,13441,13442,13443,13444,13445,13446,13447,13448,13449,13450,13451,13452,13453,13454,13455,13456,13457,13458,13459,13460,13461,13462,13467,13468,13469,13470,13471,13472,13473,13474,13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,13487,13488,13489,13490)",
          "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": 48,
          "rows": 1,
          "cost": 0.04620992,
          "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
13439 1632M
13440 1632M
13441 1632M
13442 1632M
13443 1632M
13444 1632M
13445 1632M
13446 1632M
13447 1632M
13448 1632M
13449 1632M
13450 1632M
13451 1632M
13452 1632M
13453 1632M
13454 1632M
13455 1632M
13456 1632M
13457 1632M
13458 1632M
13459 1632M
13460 1632M
13461 1632M
13462 1632M
13467 1632M
13468 1632M
13469 1632M
13470 1632M
13471 1632M
13472 1632M
13473 1632M
13474 1632M
13475 1632M
13476 1632M
13477 1632M
13478 1632M
13479 1632M
13480 1632M
13481 1632M
13482 1632M
13483 1632M
13484 1632M
13485 1632M
13486 1632M
13487 1632M
13488 1632M
13489 1632M
13490 1632M