SELECT 
  ushop_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      ushop_products_categories.link_type = "M", 
      CONCAT(
        ushop_products_categories.category_id, 
        "M"
      ), 
      ushop_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  ushop_products_categories 
  INNER JOIN ushop_categories ON ushop_categories.category_id = ushop_products_categories.category_id 
  AND ushop_categories.storefront_id IN (0, 1) 
  AND (
    ushop_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, ushop_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, ushop_categories.usergroup_ids
    )
  ) 
  AND ushop_categories.status IN ('A', 'H') 
WHERE 
  ushop_products_categories.product_id IN (
    430, 428, 429, 289, 287, 307, 292, 452, 
    516, 447, 517, 296, 361, 297
  ) 
GROUP BY 
  ushop_products_categories.product_id

Query time 0.00183

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "9.31"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "0.28"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "ushop_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 63,
            "rows_produced_per_join": 2,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "7.01",
              "eval_cost": "0.25",
              "prefix_cost": "7.27",
              "data_read_per_join": "8K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`marketplace`.`ushop_categories`.`storefront_id` in (0,1)) and ((`marketplace`.`ushop_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`marketplace`.`ushop_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`marketplace`.`ushop_categories`.`usergroup_ids`))) and (`marketplace`.`ushop_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "ushop_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "marketplace.ushop_categories.category_id"
            ],
            "rows_examined_per_scan": 2,
            "rows_produced_per_join": 0,
            "filtered": "5.58",
            "index_condition": "(`marketplace`.`ushop_products_categories`.`product_id` in (430,428,429,289,287,307,292,452,516,447,517,296,361,297))",
            "cost_info": {
              "read_cost": "1.26",
              "eval_cost": "0.03",
              "prefix_cost": "9.03",
              "data_read_per_join": "4"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
287 348M
289 348M
292 348M
296 349M
297 350M
307 352M
361 359M
428 352M
429 352M
430 362M
447 367M
452 369M
516 373M
517 373M