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 (
    1501, 1487, 1498, 1497, 1496, 1491, 1495, 
    1493, 1486, 1489, 1488, 1485, 1459, 
    1477, 1484, 1483, 1482, 1480, 1481, 
    1474, 1479, 1478, 1465, 1475, 1476, 
    1473, 1276, 1463, 1471, 1462, 1267, 
    1460, 820, 1472, 1464, 1470, 1469, 1468, 
    1467, 1466, 1461, 1458, 1457, 1456, 
    1455, 1454, 1446, 1450
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00171

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 48,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (1501,1487,1498,1497,1496,1491,1495,1493,1486,1489,1488,1485,1459,1477,1484,1483,1482,1480,1481,1474,1479,1478,1465,1475,1476,1473,1276,1463,1471,1462,1267,1460,820,1472,1464,1470,1469,1468,1467,1466,1461,1458,1457,1456,1455,1454,1446,1450)"
    },
    "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": ["bacpvdev_db.cscart_products_categories.category_id"],
      "rows": 1,
      "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
820 24M
1267 13M
1276 8M
1446 46M
1450 11M
1454 43M
1455 35M
1456 35M
1457 35M
1458 35M
1459 25M
1460 35M
1461 20M
1462 8M
1463 5M
1464 35M
1465 25M
1466 36M
1467 36M
1468 36M
1469 8M
1470 8M
1471 13M
1472 24M
1473 43M
1474 25M
1475 8M
1476 43M
1477 25M
1478 17M
1479 17M
1480 36M
1481 17M
1482 36M
1483 36M
1484 36M
1485 8M
1486 13M
1487 22M
1488 46M
1489 46M
1491 8M
1493 19M
1495 13M
1496 8M
1497 8M
1498 8M
1501 13M