SELECT 
  netting_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      netting_products_categories.link_type = "M", 
      CONCAT(
        netting_products_categories.category_id, 
        "M"
      ), 
      netting_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  netting_products_categories 
  INNER JOIN netting_categories ON netting_categories.category_id = netting_products_categories.category_id 
  AND netting_categories.storefront_id IN (0, 1) 
  AND (
    netting_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, netting_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, netting_categories.usergroup_ids
    )
  ) 
  AND netting_categories.status IN ('A', 'H') 
WHERE 
  netting_products_categories.product_id IN (
    531, 533, 534, 535, 536, 537, 538, 539, 
    540, 541, 542, 543, 544, 545, 546, 547, 
    569, 570, 571, 572, 592, 593, 594, 595, 
    596, 597, 598, 599, 600, 601, 602, 603, 
    604, 605, 606, 607, 611, 612, 706, 707, 
    708, 709, 710, 711, 712, 713, 714, 715, 
    716, 717, 718, 719, 720, 721, 757, 758, 
    759, 761, 762, 763, 764, 765, 766, 767, 
    768, 769, 770, 771, 772, 773, 774, 775, 
    776
  ) 
GROUP BY 
  netting_products_categories.product_id

Query time 0.00218

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "read_sorted_file": {
          "filesort": {
            "sort_key": "netting_products_categories.product_id",
            "table": {
              "table_name": "netting_products_categories",
              "access_type": "ALL",
              "possible_keys": ["PRIMARY", "pt"],
              "rows": 724,
              "filtered": 35.49723816,
              "attached_condition": "netting_products_categories.product_id in (531,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,569,570,571,572,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,611,612,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,757,758,759,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776)"
            }
          }
        }
      },
      {
        "table": {
          "table_name": "netting_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["pucuda_cscart.netting_products_categories.category_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "netting_categories.storefront_id in (0,1) and (netting_categories.usergroup_ids = '' or find_in_set(0,netting_categories.usergroup_ids) or find_in_set(1,netting_categories.usergroup_ids)) and netting_categories.`status` in ('A','H')"
        }
      }
    ]
  }
}

Result

product_id category_ids
531 318,378,366,362M
533 378,366,318,362M
534 362M,378,366,318
535 318,366,362M,378
536 366,378,318,362M
537 318,378,362M,366
538 362M,378,366,318
539 378,366,318,362M
540 378,318,362M,366
541 366,378,362M,318
542 378,362M,366,318
543 318,378,366,362M
544 362M,378,318,366
545 318,378,362M,366
546 362M,318,378,366
547 378,362M,366,318
569 366,318,378,362M
570 378,318,362M,366
571 366,318,378,362M
572 362M,366,318,378
592 378,362M,366,318
593 362M,366,378,318
594 318,366,378,362M
595 366,318,362M,378
596 362M,366,318,378
597 378,366,318,362M
598 366,318,362M,378
599 362M,378,318,366
600 366,378,362M,318
601 366,362M,378,318
602 378,362M,318,366
603 378,362M,366,318
604 378,366,318,362M
605 366,318,362M,378
606 362M,378,318,366
607 318,378,362M,366
611 362M,378,318,366
612 318,366,378,362M
706 318,315M,322
707 322,315M,318
708 318,315M,322
709 318,322,315M
710 322,315M,318
711 318,322,315M
712 318,322,315M
713 315M,318,322
714 318,315M,322
715 322,318,315M
716 322,318,315M
717 315M,318,322
718 322,315M,318
719 322,315M,318
720 315M,318,322
721 315M,318,322
757 318,315M,322
758 315M,322,318
759 315M,318,322
761 315M,318,322
762 318,315M,322
763 318,315M,322
764 315M,318,322
765 318,322,315M
766 322,315M,318
767 322,315M,318
768 322,318,315M
769 322,315M,318
770 318,315M,322
771 315M,322,318
772 315M,322,318
773 318,315M,322
774 318,315M,322
775 322,318,315M
776 315M,322,318