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 (
    9743, 10015, 10017, 9721, 9748, 9906, 
    10018, 10331, 10019, 10338, 9761, 10001, 
    9752, 10362, 9722, 9745, 10337, 10000, 
    9746, 10002, 9720, 9998, 10003, 9755, 
    9995, 9999, 9763, 9912, 10342, 9911, 
    9992, 10014, 10306, 10334, 9900, 10330, 
    9910, 10301, 9759, 9905, 10300, 10304, 
    10307, 10308, 10332, 10340, 9750, 9867, 
    10302, 10333, 10336, 10341, 10343, 
    10363, 9757, 9902, 9908, 9984, 9990, 
    10016, 10305, 10329, 10335, 10339, 
    9873, 9891, 9889, 9893, 9987, 10303, 
    9896, 9899, 9986
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00174

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "77.46"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 74,
            "rows_produced_per_join": 74,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (9743,10015,10017,9721,9748,9906,10018,10331,10019,10338,9761,10001,9752,10362,9722,9745,10337,10000,9746,10002,9720,9998,10003,9755,9995,9999,9763,9912,10342,9911,9992,10014,10306,10334,9900,10330,9910,10301,9759,9905,10300,10304,10307,10308,10332,10340,9750,9867,10302,10333,10336,10341,10343,10363,9757,9902,9908,9984,9990,10016,10305,10329,10335,10339,9873,9891,9889,9893,9987,10303,9896,9899,9986))",
            "cost_info": {
              "read_cost": "44.16",
              "eval_cost": "7.40",
              "prefix_cost": "51.56",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 3,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "18.50",
              "eval_cost": "0.37",
              "prefix_cost": "77.46",
              "data_read_per_join": "11K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
9720 661M
9721 661M
9722 661M
9743 661M
9745 661M
9746 661M
9748 661M
9750 661M
9752 661M
9755 661M
9757 661M
9759 661M
9761 661M
9763 661M
9867 661M
9873 661M
9889 661M
9891 661M
9893 661M
9896 661M
9899 661M
9900 661M
9902 661M
9905 661M
9906 661M
9908 661M
9910 661M
9911 661M
9912 661M
9984 661M
9986 661M
9987 661M
9990 661M
9992 661M
9995 661M
9998 661M
9999 661M
10000 661M
10001 661M
10002 661M
10003 661M
10014 661M
10015 661M
10016 661M
10017 661M
10018 661M
10019 661M
10300 661M
10301 661M
10302 661M
10303 661M
10304 661M
10305 661M
10306 661M
10307 661M
10308 661M
10329 661M
10330 661M
10331 661M
10332 661M
10333 661M
10334 661M
10335 661M
10336 661M
10337 661M
10338 661M
10339 661M
10340 661M
10341 661M
10342 661M
10343 661M
10362 661M
10363 661M