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 (
    1615, 1616, 2593, 2594, 2595, 2617, 2618, 
    2649, 2650, 2788, 2789, 2790, 2791, 
    2877, 2878, 2879, 2938, 2939, 2940, 
    2941, 3034, 3033, 3104, 3105, 3106, 
    3112, 3113, 3609, 3370, 3371, 3664, 
    3665, 7608, 7279, 7283, 7616, 7285, 
    7620, 7619, 7618, 7617, 7293, 7625, 
    8474, 8475, 2441
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00215

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "101.11"
    },
    "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": 112,
            "rows_produced_per_join": 112,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (1615,1616,2593,2594,2595,2617,2618,2649,2650,2788,2789,2790,2791,2877,2878,2879,2938,2939,2940,2941,3034,3033,3104,3105,3106,3112,3113,3609,3370,3371,3664,3665,7608,7279,7283,7616,7285,7620,7619,7618,7617,7293,7625,8474,8475,2441))",
            "cost_info": {
              "read_cost": "50.71",
              "eval_cost": "11.20",
              "prefix_cost": "61.91",
              "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": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "28.00",
              "eval_cost": "0.56",
              "prefix_cost": "101.11",
              "data_read_per_join": "17K"
            },
            "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
1615 166,378,379M
1616 378,166,379M
2441 454,453,166,372,174,190M
2593 329,166,457M
2594 166,329,457M
2595 166,329,457M
2617 166,329,457M
2618 329,166,457M
2649 167,166,444M
2650 166,167,444M
2788 329,166,344M
2789 166,329,344M
2790 166,329,344M
2791 166,329,344M
2877 329,166,344M
2878 329,166,344M
2879 329,166,344M
2938 329,166,347M
2939 329,166,347M
2940 329,166,347M
2941 329,166,347M
3033 320,166,469M
3034 320,166,469M
3104 329,166,457M
3105 329,166,457M
3106 329,166,457M
3112 423,424,452,166M
3113 423,424,452,166M
3370 166,378,490M
3371 378,166,490M
3609 166,378,490M
3664 423,424,450,166M
3665 423,424,450,166M
7279 190,454M
7283 454,190M
7285 190,454M
7293 190,454M
7608 190,454M
7616 454,190M
7617 190,454M
7618 190,454M
7619 190,454M
7620 190,454M
7625 190,454M
8474 166,453,174,454,372,190M
8475 166,174,453,454,372,190M