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 (
    35, 47, 81, 107, 109, 91, 92, 161, 188, 
    202, 203, 34, 31, 38, 80, 165, 166, 86, 
    106, 105, 247, 101, 33, 32, 163, 244, 
    212, 155, 102, 12, 564, 570
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00109

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "41.93"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "2.39"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 113,
            "rows_produced_per_join": 4,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "22.70",
              "eval_cost": "0.90",
              "prefix_cost": "23.60",
              "data_read_per_join": "11K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`twebezli_Commercemodalpopup`.`cscart_categories`.`storefront_id` in (0,1)) and ((`twebezli_Commercemodalpopup`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`twebezli_Commercemodalpopup`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`twebezli_Commercemodalpopup`.`cscart_categories`.`usergroup_ids`)) and (`twebezli_Commercemodalpopup`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "twebezli_Commercemodalpopup.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 12,
            "rows_produced_per_join": 2,
            "filtered": "4.22",
            "cost_info": {
              "read_cost": "4.58",
              "eval_cost": "0.48",
              "prefix_cost": "39.54",
              "data_read_per_join": "38"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`twebezli_Commercemodalpopup`.`cscart_products_categories`.`product_id` in (35,47,81,107,109,91,92,161,188,202,203,34,31,38,80,165,166,86,106,105,247,101,33,32,163,244,212,155,102,12,564,570))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
12 224M
31 225M
32 176M
33 176M
34 225M
35 220M
38 225M
47 247M
80 226M
81 226M
86 238M
91 227M
92 227M
101 238M
102 227M
105 238M
106 238M
107 227M
109 227M
155 181M
161 199,198M
163 199,198M
165 199,198M
166 199,198M
188 213M
202 230M
203 230M
212 172M
244 168M
247 165M
564 166M
570 166M