WC_REST_Products_V2_Controller::batch_items
Bulk create, update, and delete items.
This method extends the parent batch_items functionality by deferring term counting to optimize performance when processing multiple products that may share common terms.
Метод класса: WC_REST_Products_V2_Controller{}
Хуков нет.
Возвращает
Массив. Array of WP_Error or WP_REST_Response objects for each processed item.
Использование
$WC_REST_Products_V2_Controller = new WC_REST_Products_V2_Controller(); $WC_REST_Products_V2_Controller->batch_items( $request );
- $request(WP_REST_Request) (обязательный)
- Full details about the request containing arrays of products to create, update, or delete.
Список изменений
| С версии 10.4.0 | Введена. |
| С версии 10.4.0 | Added term counting optimization for bulk operations. |
Код WC_REST_Products_V2_Controller::batch_items() WC REST Products V2 Controller::batch items WC 10.5.2
public function batch_items( $request ) {
$already_deferred = wp_defer_term_counting();
wp_defer_term_counting( true );
try {
return parent::batch_items( $request );
} finally {
// Be sure to trigger term counting already processed terms even if there was an exception unless something had already deferred it.
wp_defer_term_counting( $already_deferred );
}
}