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 (
    639, 640, 641, 642, 643, 644, 645, 646, 
    647, 648, 649, 650, 651, 652, 653, 654, 
    655, 656, 657, 658, 659, 660, 661, 662, 
    663, 664, 665, 666, 667, 668, 669, 670, 
    671, 672, 673, 674, 675, 676, 677, 678, 
    679, 680, 681, 682, 683, 684, 685, 686, 
    687, 688, 689, 690, 691, 692, 693, 694, 
    695, 696, 697, 698, 699, 700, 701, 702, 
    703, 704, 705, 706, 707, 708, 709, 710, 
    711, 712, 713, 714, 715, 716, 717, 718, 
    719, 720, 721, 722, 723, 724, 725, 726, 
    727, 728, 729, 730, 731, 732, 733, 734
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00286

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": 96,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734)"
    },
    "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
639 19M
640 19M
641 19M
642 19M
643 19M
644 19M
645 19M
646 19M
647 16M
648 33M
649 16M
650 29M
651 29M
652 29M
653 25M
654 29M
655 16M
656 16M
657 16M
658 16M
659 16M
660 16M
661 27M
662 27M
663 27M
664 27M
665 8M
666 27M
667 27M
668 27M
669 27M
670 16M
671 16M
672 16M
673 27M
674 27M
675 27M
676 27M
677 27M
678 27M
679 27M
680 27M
681 20M
682 9M
683 12M
684 34M
685 39M
686 39M
687 31M
688 31M
689 31M
690 31M
691 16M
692 39M
693 16M
694 33M
695 33M
696 31M
697 31M
698 16M
699 24M
700 16M
701 24M
702 16M
703 24M
704 16M
705 16M
706 24M
707 16M
708 25M
709 16M
710 24M
711 24M
712 16M
713 19M
714 8M
715 8M
716 27M
717 15M
718 15M
719 27M
720 27M
721 16M
722 16M
723 16M
724 33M
725 27M
726 8M
727 8M
728 9M
729 8M
730 17M
731 9M
732 21M
733 21M
734 21M