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 (
    232, 298, 309, 337, 339, 405, 427, 428, 
    429, 430, 431, 520, 521, 522, 523, 550, 
    551, 552, 553, 554, 555, 556, 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, 
    3314, 3315, 3478, 3479, 3480, 5556, 
    5473, 5475, 533, 1843, 531, 1841, 536, 
    1840, 486, 534, 532, 1842, 292, 535
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01284

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": 1560,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (232,298,309,337,339,405,427,428,429,430,431,520,521,522,523,550,551,552,553,554,555,556,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,3314,3315,3478,3479,3480,5556,5473,5475,533,1843,531,1841,536,1840,486,534,532,1842,292,535)"
    },
    "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
232 242,306,264,238,237,236,235,234,233,206,83,82,73,68,67,62,61,18,17,16,15,336,6M
292 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
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
309 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,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
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
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
531 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
532 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
533 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
534 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
535 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
536 228,304,264,236,235,234,233,210,208,123,87,82,81,73,67,57,49,38,19,18,17,15,306,217M
550 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
551 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
552 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
553 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
554 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
555 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
556 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
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
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
3314 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
3315 306,304,267,265,241,234,233,119,93,90,81,77,71,67,56,49,238,217M
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
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
5475 306,15,17,18,19,38,49,57,67,73,81,82,87,123,208,210,233,234,235,236,264,304,228,217M
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