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 (
    8607, 8700, 8725, 8798, 8807, 8271, 8274, 
    8278, 8279, 8285, 8287, 8330, 8333, 
    8374, 8389, 8405, 8430, 8458, 8465, 
    8516, 8518, 8537, 8571, 8582, 8584, 
    8588, 8599, 8726, 8728, 8755, 8756, 
    8803, 8809, 8268, 8331, 8334, 8378, 
    8383, 8436, 8442, 8462, 8539, 8541, 
    8579, 8583, 8606, 8727, 8239, 8270, 
    8286, 8376, 8384, 8401, 8402, 8437, 
    8467, 8468, 8515, 8531, 8533, 8542, 
    8616, 8698, 8707, 8386, 8404, 8449, 
    8522, 8591, 8592, 8598, 8786, 8808
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00263

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "83.06"
    },
    "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": 81,
            "rows_produced_per_join": 81,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (8607,8700,8725,8798,8807,8271,8274,8278,8279,8285,8287,8330,8333,8374,8389,8405,8430,8458,8465,8516,8518,8537,8571,8582,8584,8588,8599,8726,8728,8755,8756,8803,8809,8268,8331,8334,8378,8383,8436,8442,8462,8539,8541,8579,8583,8606,8727,8239,8270,8286,8376,8384,8401,8402,8437,8467,8468,8515,8531,8533,8542,8616,8698,8707,8386,8404,8449,8522,8591,8592,8598,8786,8808))",
            "cost_info": {
              "read_cost": "46.61",
              "eval_cost": "8.10",
              "prefix_cost": "54.71",
              "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": "20.25",
              "eval_cost": "0.41",
              "prefix_cost": "83.06",
              "data_read_per_join": "12K"
            },
            "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
8239 423M
8268 424,450M
8270 450M
8271 449M
8274 449M
8278 449M
8279 423M
8285 450M
8286 542,450M
8287 424,450M
8330 423,450M
8331 423,450M
8333 449M
8334 449M
8374 166,426M
8376 166,450M
8378 450M
8383 449M
8384 423,451M
8386 449M
8389 449M
8401 449M
8402 450M
8404 424,492M
8405 448M
8430 449M
8436 423,451M
8437 448M
8442 450M
8449 424,450M
8458 457M
8462 449M
8465 344M
8467 423,451M
8468 424,450M
8515 448M
8516 449M
8518 449M
8522 492M
8531 424,451,492M
8533 450M
8537 449M
8539 423,449M
8541 658M
8542 448M
8571 424,450M
8579 450M
8582 658M
8583 492M
8584 448M
8588 448M
8591 423,426M
8592 450M
8598 492M
8599 658M
8606 542,450M
8607 423M
8616 450M
8698 426M
8700 450M
8707 552M
8725 347M
8726 426M
8727 492M
8728 492M
8755 449M
8756 347M
8786 450M
8798 449M
8803 492M
8807 344M
8808 450M
8809 344M