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 (
    55, 143, 232, 298, 337, 339, 405, 427, 
    428, 429, 430, 431, 506, 516, 517, 520, 
    521, 522, 523, 1562, 1563, 1564, 1565, 
    1566, 1567, 1568, 1569, 1570, 1755, 
    1756, 1757, 1758, 1759, 1760, 1761, 
    1762, 1763, 1764, 1765, 1766, 1767, 
    1768, 1769, 1770, 1771, 3478, 3479, 
    3480, 5477, 5556
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01078

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": 1179,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (55,143,232,298,337,339,405,427,428,429,430,431,506,516,517,520,521,522,523,1562,1563,1564,1565,1566,1567,1568,1569,1570,1755,1756,1757,1758,1759,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,3478,3479,3480,5477,5556)"
    },
    "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
55 261,257,249,243,241,240,237,107,100,75,48,44,27,26,20,18,16,306,1M
143 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
232 242,306,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
298 267,261,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
337 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
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
405 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
427 261,267,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
428 261,267,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
429 261,267,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
430 261,267,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
431 261,267,259,306,241,238,237,236,235,234,233,227,226,93,89,85,82,80,79,75,67,57,56,43,217M
506 261,257,249,243,241,240,237,107,100,75,48,44,27,26,20,18,16,306,1M
516 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
517 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
520 306,242,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
521 306,242,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
522 306,242,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
523 306,242,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
1562 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
1563 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
1564 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
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
1755 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1756 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1757 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1758 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1759 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1760 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1761 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1762 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1763 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1764 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1765 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1766 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1767 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1768 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1769 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1770 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
1771 309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,311,50,337,6M
3478 50,311,309,306,237,16,234,246,238,75,181,54,91,179,77,90,67,86,62,233,337,6M
3479 237,86,311,50,67,179,233,62,77,91,90,181,54,75,238,306,246,234,16,309,337,6M
3480 86,311,50,67,62,90,246,181,54,77,179,91,233,75,238,309,234,16,237,306,337,6M
5477 306,1,20,30,42,43,44,48,60,71,73,75,123,194,217,233,236,237,238,241,258,259,261,242M
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