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 (
    10447, 10460, 10400, 10397, 10399, 10403, 
    10402, 10401, 10404, 10356, 10351, 
    10368, 10009, 10012, 10474, 10420, 
    10387, 10354, 10428, 10453, 10471, 
    10365, 10398, 10463, 10406, 10436, 
    10480, 10486, 10545, 10350, 10412, 
    10488, 10384, 10449, 10452, 10462, 
    10461, 10472, 10482, 10553
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00127

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "46.01"
    },
    "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": 45,
            "rows_produced_per_join": 45,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (10447,10460,10400,10397,10399,10403,10402,10401,10404,10356,10351,10368,10009,10012,10474,10420,10387,10354,10428,10453,10471,10365,10398,10463,10406,10436,10480,10486,10545,10350,10412,10488,10384,10449,10452,10462,10461,10472,10482,10553))",
            "cost_info": {
              "read_cost": "25.76",
              "eval_cost": "4.50",
              "prefix_cost": "30.26",
              "data_read_per_join": "720"
            },
            "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": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "11.25",
              "eval_cost": "0.23",
              "prefix_cost": "46.01",
              "data_read_per_join": "7K"
            },
            "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
10009 573M
10012 574M
10350 474M
10351 474M
10354 475M
10356 475M
10365 372M
10368 372M
10384 575M
10387 372,587M
10397 460,384M
10398 598M
10399 598,384M
10400 460,384M
10401 384M
10402 384M
10403 384M
10404 384M
10406 574M
10412 554,556M
10420 574M
10428 466,467M
10436 587M
10447 578M
10449 578M
10452 597M
10453 597M
10460 566,597M
10461 566,597M
10462 566,597M
10463 566,597M
10471 384M
10472 423M
10474 423M
10480 573M
10482 574M
10486 574M
10488 574M
10545 579M
10553 466M