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 (
    5549, 5661, 5660, 5523, 5666, 5665, 5655, 
    5663, 5664, 5650, 5652, 5474, 5682, 
    5452, 5527, 5425, 5494, 5653, 5593, 
    5488, 5492, 5453, 5491, 9784, 5578, 
    5446, 5414, 5408, 5411, 5536, 5551, 
    5553, 5515, 5435, 5454, 5668, 5415, 
    5581, 5409, 5422
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00299

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "83.61"
    },
    "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": 92,
            "rows_produced_per_join": 92,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (5549,5661,5660,5523,5666,5665,5655,5663,5664,5650,5652,5474,5682,5452,5527,5425,5494,5653,5593,5488,5492,5453,5491,9784,5578,5446,5414,5408,5411,5536,5551,5553,5515,5435,5454,5668,5415,5581,5409,5422))",
            "cost_info": {
              "read_cost": "42.21",
              "eval_cost": "9.20",
              "prefix_cost": "51.41",
              "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": "23.00",
              "eval_cost": "0.46",
              "prefix_cost": "83.61",
              "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
5408 473,577,474M
5409 473,577,474M
5411 473,577,474M
5414 473,577,474M
5415 473,577,474M
5422 473,577,476M
5425 577,578M
5435 466,372,574M
5446 466,372,574M
5452 466,372,574M
5453 466,372,574M
5454 466,372,574M
5474 466,372,574M
5488 466,372,575M
5491 466,372,575M
5492 466,372,575M
5494 466,372,575M
5515 466,372,573M
5523 466,372,573M
5527 466,372,467M
5536 466,372,579M
5549 553,250,552,554,372,556M
5551 372,466M
5553 466,372,581M
5578 572,372,582M
5581 572,372,582M
5593 466,372,573M
5650 372,384,460M
5652 372,384,460M
5653 372,384,598M
5655 372,384,598M
5660 372,587M
5661 372,587M
5663 372,587M
5664 372,587M
5665 372,587M
5666 372,587M
5668 566,372,596M
5682 461,372,462M
9784 662M