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, 2522, 2655, 2719, 2728, 3112, 
    3113, 3153, 3289, 3377, 3378, 3382, 
    3383, 3385, 3386, 3664, 3665, 3832, 
    3831, 4110, 4111, 3811, 5948, 6128, 
    6127, 6126, 6129, 6130, 6131, 6132, 
    6133, 6134, 6135, 6041, 6042, 6043, 
    6044, 6045, 6046, 6047, 6054, 6055, 
    6056, 6057, 6058, 6059, 5956, 6087, 
    6088, 6089, 6090, 6091, 6092, 6093, 
    5683, 6152, 6153, 6154, 6155, 6196, 
    6195, 6194, 6197, 6198, 6199, 6200, 
    6201, 6202
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00354

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "166.86"
    },
    "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": 187,
            "rows_produced_per_join": 187,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (2227,2226,2522,2655,2719,2728,3112,3113,3153,3289,3377,3378,3382,3383,3385,3386,3664,3665,3832,3831,4110,4111,3811,5948,6128,6127,6126,6129,6130,6131,6132,6133,6134,6135,6041,6042,6043,6044,6045,6046,6047,6054,6055,6056,6057,6058,6059,5956,6087,6088,6089,6090,6091,6092,6093,5683,6152,6153,6154,6155,6196,6195,6194,6197,6198,6199,6200,6201,6202))",
            "cost_info": {
              "read_cost": "82.71",
              "eval_cost": "18.70",
              "prefix_cost": "101.41",
              "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": 9,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "46.75",
              "eval_cost": "0.94",
              "prefix_cost": "166.86",
              "data_read_per_join": "29K"
            },
            "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
2522 423,424,452,166M
2655 423,424,450,166M
2719 423,424,450,166M
2728 423,424,450,166M
3112 423,424,452,166M
3113 423,424,452,166M
3153 423,451,424,166M
3289 450,424,423,166M
3377 492,424,423,166M
3378 492,423,424,166M
3382 423,424,450,166M
3383 423,424,450,166M
3385 423,424,450,166M
3386 423,424,450,166M
3664 423,424,450,166M
3665 423,424,450,166M
3811 423,449,166M
3831 423,424,450,166M
3832 424,450,423,166M
4110 423,449,166M
4111 449,423,166M
5683 423,585,166M
5948 423,166,585M
5956 166,423,449M
6041 423,166,585M
6042 423,166,585M
6043 423,166,585M
6044 423,166,585M
6045 423,166,585M
6046 423,166,585M
6047 166,423,585M
6054 423,166,585M
6055 166,423,585M
6056 423,166,585M
6057 423,166,585M
6058 423,166,585M
6059 423,166,585M
6087 166,423,449M
6088 166,423,449M
6089 166,423,449M
6090 166,423,449M
6091 423,166,449M
6092 166,423,449M
6093 423,166,449M
6126 423,166,585M
6127 423,166,585M
6128 423,166,585M
6129 423,166,585M
6130 423,166,585M
6131 423,166,585M
6132 423,166,585M
6133 423,166,585M
6134 423,166,585M
6135 423,166,585M
6152 423,585,166M
6153 423,585,166M
6154 423,585,166M
6155 423,585,166M
6194 423,166,449M
6195 423,166,449M
6196 166,423,449M
6197 166,423,449M
6198 166,423,449M
6199 423,166,449M
6200 423,166,449M
6201 423,166,449M
6202 423,166,449M