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 (
    2227, 2226, 2430, 2431, 2655, 2698, 2702, 
    2703, 2719, 2728, 2918, 2919, 2922, 
    2923, 3150, 3151, 3213, 3214, 3216, 
    3215, 3220, 3221, 3222, 3223, 3289, 
    3310, 3309, 3382, 3383, 3385, 3386, 
    3522, 3523, 3532, 3533, 3552, 3553, 
    3664, 3665, 3832, 3831, 3834, 3835, 
    3668, 4102, 4103, 3682, 4106, 3684, 
    5117, 5116, 5114, 5804, 6193
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00468

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "154.31"
    },
    "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": 176,
            "rows_produced_per_join": 176,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (2227,2226,2430,2431,2655,2698,2702,2703,2719,2728,2918,2919,2922,2923,3150,3151,3213,3214,3216,3215,3220,3221,3222,3223,3289,3310,3309,3382,3383,3385,3386,3522,3523,3532,3533,3552,3553,3664,3665,3832,3831,3834,3835,3668,4102,4103,3682,4106,3684,5117,5116,5114,5804,6193))",
            "cost_info": {
              "read_cost": "75.11",
              "eval_cost": "17.60",
              "prefix_cost": "92.71",
              "data_read_per_join": "2K"
            },
            "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": 8,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.88",
              "prefix_cost": "154.31",
              "data_read_per_join": "27K"
            },
            "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
2226 424,423,450,166M
2227 423,424,450,166M
2430 423,424,450,166M
2431 423,424,450,166M
2655 423,424,450,166M
2698 450,424,423,166M
2702 423,424,450,166M
2703 423,424,450,166M
2719 423,424,450,166M
2728 423,424,450,166M
2918 423,424,450,166M
2919 423,424,450,166M
2922 423,424,450,166M
2923 423,424,450,166M
3150 423,424,450,166M
3151 423,424,450,166M
3213 450,423,424,166M
3214 450,424,423,166M
3215 450,424,423,166M
3216 450,423,424,166M
3220 450,424,423,166M
3221 450,423,424,166M
3222 450,424,423,166M
3223 450,423,424,166M
3289 450,424,423,166M
3309 423,450,424,166M
3310 423,450,424,166M
3382 423,424,450,166M
3383 423,424,450,166M
3385 423,424,450,166M
3386 423,424,450,166M
3522 423,424,450,166M
3523 423,424,450,166M
3532 423,424,450,166M
3533 423,424,450,166M
3552 423,424,450,166M
3553 423,424,450,166M
3664 423,424,450,166M
3665 423,424,450,166M
3668 166,424,423,450M
3682 424,166,423,450M
3684 424,166,423,450M
3831 423,424,450,166M
3832 424,450,423,166M
3834 423,424,450,166M
3835 423,424,450,166M
4102 166,423,424,450M
4103 423,424,166,450M
4106 424,166,423,450M
5114 450,423,424,166M
5116 450,423,424,166M
5117 450,423,424,166M
5804 423,424,450,166M
6193 423,450,424,166M