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 (
    73, 303, 339, 507, 508, 537, 1565, 1566, 
    1567, 1568, 1569, 1570, 5556, 5473, 
    5474, 504, 1843, 1841, 1855, 1840, 1853, 
    486, 1854, 1842
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00629

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": 754,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (73,303,339,507,508,537,1565,1566,1567,1568,1569,1570,5556,5473,5474,504,1843,1841,1855,1840,1853,486,1854,1842)"
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["herbaria_cscart_4_18.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
73 304,261,257,243,240,239,235,234,107,67,46,36,35,34,33,26,25,17,16,306,1M
303 269,261,257,249,243,240,107,46,40,39,36,35,33,27,26,21,306,1M
339 258,306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,15,336,1M
486 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
504 335,333,334,306,261,257,243,240,239,235,234,67,46,36,35,34,33,25,17,16,298,297,1M
507 304,261,257,243,240,239,235,234,107,67,46,36,35,34,33,26,25,17,16,306,1M
508 304,261,257,243,240,239,235,234,107,67,46,36,35,34,33,26,25,17,16,306,1M
537 269,261,257,249,243,240,107,46,40,39,36,35,33,27,26,21,306,1M
1565 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1566 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1567 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1568 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1569 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1570 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1840 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1841 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1842 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1843 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1853 335,333,334,306,261,257,243,240,239,235,234,67,46,36,35,34,33,25,17,16,298,297,1M
1854 335,333,334,306,261,257,243,240,239,235,234,67,46,36,35,34,33,25,17,16,298,297,1M
1855 335,333,334,306,261,257,243,240,239,235,234,67,46,36,35,34,33,25,17,16,298,297,1M
5473 83,61,1,20,44,73,75,233,236,241,258,261,306,67,94,46,47,95,88,107,76,77,81,90,70,87,242M
5474 297,298,16,17,25,33,34,35,36,46,67,234,235,239,240,243,257,261,306,334,333,335,1M
5556 261,20,255,26,251,241,240,238,237,236,235,15,234,233,230,229,192,179,336,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,258,306,304,295,267,16,265,17,264,19,1M