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 (
    1557, 1556, 1555, 1554, 1553, 1551, 1549, 
    1546, 1545, 1544, 1543, 1542, 1541, 
    1540, 1539, 1538, 1537, 1512, 1534, 
    1533, 1515, 1532, 1531, 1530, 1529, 
    1528, 1527, 1526, 1508, 1525, 1524, 
    1509, 1523, 1522, 1521, 1520, 1519, 
    1518, 1517, 1516, 1277, 1494, 1507, 
    1499, 1505, 1504, 1503, 1502
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00167

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 (1557,1556,1555,1554,1553,1551,1549,1546,1545,1544,1543,1542,1541,1540,1539,1538,1537,1512,1534,1533,1515,1532,1531,1530,1529,1528,1527,1526,1508,1525,1524,1509,1523,1522,1521,1520,1519,1518,1517,1516,1277,1494,1507,1499,1505,1504,1503,1502)"
    },
    "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
1277 13M
1494 25M
1499 13M
1502 13M
1503 13M
1504 13M
1505 34M
1507 8M
1508 13M
1509 13M
1512 13M
1515 13M
1516 8M
1517 8M
1518 8M
1519 8M
1520 8M
1521 8M
1522 8M
1523 8M
1524 13M
1525 13M
1526 13M
1527 13M
1528 13M
1529 13M
1530 13M
1531 13M
1532 13M
1533 13M
1534 13M
1537 13M
1538 13M
1539 13M
1540 13M
1541 13M
1542 13M
1543 13M
1544 13M
1545 8M
1546 13M
1549 8M
1551 8M
1553 13M
1554 13M
1555 13M
1556 13M
1557 13M