Merge pull request #28177 from davefx/patch-11

Optimizing memory usage
This commit is contained in:
Roy Ho 2020-11-10 06:13:03 -08:00 committed by GitHub
commit 4954c17e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1572,10 +1572,15 @@ class WC_AJAX {
$data_store = WC_Data_Store::load( 'product' );
$ids = $data_store->search_products( $term, '', (bool) $include_variations, false, $limit, $include_ids, $exclude_ids );
$product_objects = array_filter( array_map( 'wc_get_product', $ids ), 'wc_products_array_filter_readable' );
$products = array();
$products = array();
foreach ( $ids as $id ) {
$product_object = wc_get_product( $id );
if ( ! wc_products_array_filter_readable( $product_object ) ) {
continue;
}
foreach ( $product_objects as $product_object ) {
$formatted_name = $product_object->get_formatted_name();
$managing_stock = $product_object->managing_stock();