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 (
    7401, 7394, 7462, 7420, 7400, 7441, 7035, 
    7410, 7393, 7402, 7409, 7404, 7396, 
    7395, 7403, 7405, 7034, 7399, 7407, 
    7447, 7408, 7434, 7448, 7360, 7449, 
    7458, 7421, 7424, 7433, 7425, 7436, 
    7440, 7444, 7445, 7457, 7459, 7460, 
    7428, 7442, 7461, 7463, 7426, 7432, 
    7453, 7398, 7451, 7452, 7397, 7450, 
    7454, 7455, 7456, 7358
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00160

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "55.66"
    },
    "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": 53,
            "rows_produced_per_join": 53,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (7401,7394,7462,7420,7400,7441,7035,7410,7393,7402,7409,7404,7396,7395,7403,7405,7034,7399,7407,7447,7408,7434,7448,7360,7449,7458,7421,7424,7433,7425,7436,7440,7444,7445,7457,7459,7460,7428,7442,7461,7463,7426,7432,7453,7398,7451,7452,7397,7450,7454,7455,7456,7358))",
            "cost_info": {
              "read_cost": "31.81",
              "eval_cost": "5.30",
              "prefix_cost": "37.11",
              "data_read_per_join": "848"
            },
            "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": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "13.25",
              "eval_cost": "0.27",
              "prefix_cost": "55.66",
              "data_read_per_join": "8K"
            },
            "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
7034 620M
7035 618M
7358 651M
7360 651M
7393 651M
7394 651M
7395 651M
7396 651M
7397 651M
7398 651M
7399 651M
7400 651M
7401 651M
7402 651M
7403 651M
7404 651M
7405 651M
7407 651M
7408 651M
7409 651M
7410 651M
7420 651M
7421 651M
7424 651M
7425 651M
7426 651M
7428 651M
7432 651M
7433 651M
7434 651M
7436 651M
7440 651M
7441 651M
7442 651M
7444 651M
7445 651M
7447 651M
7448 651M
7449 651M
7450 651M
7451 651M
7452 651M
7453 651M
7454 651M
7455 651M
7456 651M
7457 651M
7458 651M
7459 651M
7460 651M
7461 651M
7462 651M
7463 651M