SELECT 
  products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      products_categories.link_type = "M", 
      CONCAT(
        products_categories.category_id, 
        "M"
      ), 
      products_categories.category_id
    )
  ) AS category_ids 
FROM 
  products_categories 
  INNER JOIN categories ON categories.category_id = products_categories.category_id 
  AND categories.storefront_id IN (0, 1) 
  AND (
    categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, categories.usergroup_ids) 
    OR FIND_IN_SET(1, categories.usergroup_ids)
  ) 
  AND categories.status IN ('A', 'H') 
WHERE 
  products_categories.product_id IN (
    273653, 274149, 273584, 274159, 273774, 
    273917, 274014, 274052, 277121, 276772, 
    273782, 274054, 274290, 273809, 273807, 
    285487, 276798, 287053, 285573, 291359, 
    393245, 340444, 333844, 345724
  ) 
GROUP BY 
  products_categories.product_id

Query time 0.00113

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "26.13"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 47,
            "rows_produced_per_join": 47,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "4.98",
              "eval_cost": "4.70",
              "prefix_cost": "9.68",
              "data_read_per_join": "752"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`goimagine`.`products_categories`.`product_id` in (273653,274149,273584,274159,273774,273917,274014,274052,277121,276772,273782,274054,274290,273809,273807,285487,276798,287053,285573,291359,393245,340444,333844,345724))"
          }
        },
        {
          "table": {
            "table_name": "categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "goimagine.products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 2,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "11.75",
              "eval_cost": "0.24",
              "prefix_cost": "26.13",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`goimagine`.`categories`.`storefront_id` in (0,1)) and ((`goimagine`.`categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`goimagine`.`categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`goimagine`.`categories`.`usergroup_ids`))) and (`goimagine`.`categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
273584 23,4M
273653 23,4M
273774 23,4M
273782 23,4M
273807 23,4M
273809 109,4M
273917 80,92M
274014 20,3M
274052 363M
274054 363,357M
274149 193,4M
274159 193,45M
274290 209,23M
276772 363,357M
276798 193,45M
277121 92,80M
285487 193,45M
285573 193,45M
287053 36,23M
291359 369,14M
333844 20,3M
340444 20,3M
345724 20,3M
393245 20,3M