Automattic\WooCommerce\Internal\Admin\Reports
ProductSearchQuery::get_ids
Returns the product IDs the given search terms resolve to.
For callers that need the matches themselves rather than a statement to compose with. An empty list means the terms matched nothing, which is not the same as null, meaning there was nothing to search for.
Метод класса: ProductSearchQuery{}
Хуков нет.
Возвращает
int[]|null. Matching product IDs, or null when there is nothing to search for.
Использование
$result = ProductSearchQuery::get_ids( $terms, $restrict_to_ids );
- $terms(строка|string[]) (обязательный)
- Search terms. A product matches if it matches any term.
- $restrict_to_ids(int[])
- Product IDs to intersect the results with.
По умолчанию:array()
Список изменений
| С версии 11.2.0 | Введена. |
Код ProductSearchQuery::get_ids() ProductSearchQuery::get ids WC 11.2.2
public static function get_ids( $terms, $restrict_to_ids = array() ) {
global $wpdb;
$subquery = self::get_ids_subquery( $terms, $restrict_to_ids );
if ( '' === $subquery ) {
return null;
}
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- $subquery is built from prepared fragments; the containing report is what caches.
return array_map( 'intval', $wpdb->get_col( $subquery ) );
}