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 (
    6730, 7172, 6924, 7084, 6814, 6683, 7411, 
    6684, 6685, 6686, 6687, 6688, 6689, 
    6690, 6693, 11052, 6694, 6912, 6691, 
    6913, 6682, 6695, 6696, 11104, 6692, 
    8688, 6697, 8000, 6698, 6699, 6700, 
    6701, 6702, 6703, 6704, 6705, 6707, 
    6708, 6709, 6710, 6714, 6706, 6716, 
    6717, 6718, 6715, 6719, 6720, 6721, 
    6711, 6723, 6722, 6724, 6712, 6725, 
    6726, 6727, 6728, 6729, 6731, 6732, 
    8742, 6733, 6734, 6735, 6736, 6713, 
    6737, 6738, 6739, 6740, 6741, 6742, 
    6748, 8801, 8802, 11103, 6744, 6745, 
    6746, 6747, 10992, 6749, 6750, 8743, 
    6751, 6752, 6753, 6754, 6755, 6756, 
    6757, 6758, 6759, 6760, 6915, 6916, 
    6761, 6762, 11378
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00122

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "rows": 100,
          "filtered": 100,
          "index_condition": "cscart_products_categories.product_id in (6730,7172,6924,7084,6814,6683,7411,6684,6685,6686,6687,6688,6689,6690,6693,11052,6694,6912,6691,6913,6682,6695,6696,11104,6692,8688,6697,8000,6698,6699,6700,6701,6702,6703,6704,6705,6707,6708,6709,6710,6714,6706,6716,6717,6718,6715,6719,6720,6721,6711,6723,6722,6724,6712,6725,6726,6727,6728,6729,6731,6732,8742,6733,6734,6735,6736,6713,6737,6738,6739,6740,6741,6742,6748,8801,8802,11103,6744,6745,6746,6747,10992,6749,6750,8743,6751,6752,6753,6754,6755,6756,6757,6758,6759,6760,6915,6916,6761,6762,11378)"
        }
      },
      {
        "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": ["lillyshop_lillyshop.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
6682 435M
6683 435M
6684 435M
6685 435M
6686 435M
6687 435M
6688 435M
6689 435M
6690 435M
6691 435M
6692 435M
6693 435M
6694 435M
6695 435M
6696 435M
6697 435M
6698 435M
6699 435M
6700 435M
6701 435M
6702 435M
6703 435M
6704 435M
6705 435M
6706 435M
6707 435M
6708 435M
6709 435M
6710 435M
6711 435M
6712 435M
6713 435M
6714 435M
6715 435M
6716 435M
6717 435M
6718 435M
6719 435M
6720 435M
6721 435M
6722 435M
6723 435M
6724 435M
6725 435M
6726 435M
6727 435M
6728 435M
6729 435M
6730 435M
6731 435M
6732 435M
6733 435M
6734 435M
6735 435M
6736 435M
6737 435M
6738 435M
6739 435M
6740 435M
6741 435M
6742 435M
6744 435M
6745 435M
6746 435M
6747 435M
6748 435M
6749 435M
6750 435M
6751 435M
6752 435M
6753 435M
6754 435M
6755 435M
6756 435M
6757 435M
6758 435M
6759 435M
6760 435M
6761 435M
6762 435M
6814 435M
6912 435M
6913 435M
6915 435M
6916 435M
6924 435M
7084 435M
7172 435M
7411 435M
8000 435M
8688 435M
8742 435M
8743 435M
8801 435M
8802 435M
10992 435M
11052 435M
11103 435M
11104 435M
11378 435M