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, 10381, 
    10013, 10371, 10373, 10394, 10466, 
    10467, 10551, 10011, 10370, 10372, 
    10388, 10457, 10459, 10475, 10555, 
    10007, 10008, 10010, 10352, 10353, 
    10357, 10358, 10378, 10379, 10383, 
    10392, 10393, 10405, 10411, 10414, 
    10425, 10427, 10470, 10359, 10361, 
    10376, 10390, 10426, 10429
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00250

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "92.81"
    },
    "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": 91,
            "rows_produced_per_join": 91,
            "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,10381,10013,10371,10373,10394,10466,10467,10551,10011,10370,10372,10388,10457,10459,10475,10555,10007,10008,10010,10352,10353,10357,10358,10378,10379,10383,10392,10393,10405,10411,10414,10425,10427,10470,10359,10361,10376,10390,10426,10429))",
            "cost_info": {
              "read_cost": "51.86",
              "eval_cost": "9.10",
              "prefix_cost": "60.96",
              "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": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "22.75",
              "eval_cost": "0.46",
              "prefix_cost": "92.81",
              "data_read_per_join": "14K"
            },
            "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
10007 573M
10008 573M
10009 573M
10010 573M
10011 574M
10012 574M
10013 574M
10350 474M
10351 474M
10352 474M
10353 474M
10354 475M
10356 475M
10357 466M
10358 466M
10359 466M
10361 573M
10365 372M
10368 372M
10370 474M
10371 554M
10372 556M
10373 556M
10376 574M
10378 575M
10379 575M
10381 575M
10383 575M
10384 575M
10387 372,587M
10388 372,587M
10390 587M
10392 587M
10393 587M
10394 587M
10397 460,384M
10398 598M
10399 598,384M
10400 460,384M
10401 384M
10402 384M
10403 384M
10404 384M
10405 372,574M
10406 574M
10411 554,556M
10412 554,556M
10414 466M
10420 574M
10425 466,574M
10426 466,574M
10427 466,574M
10428 466,467M
10429 578,372M
10436 587M
10447 578M
10449 578M
10452 597M
10453 597M
10457 597,566M
10459 566,597M
10460 566,597M
10461 566,597M
10462 566,597M
10463 566,597M
10466 566,597M
10467 575M
10470 466M
10471 384M
10472 423M
10474 423M
10475 423M
10480 573M
10482 574M
10486 574M
10488 574M
10545 579M
10551 466M
10553 466M
10555 655M