Skip to content

Commit

Permalink
Merge pull request #28177 from davefx/patch-11
Browse files Browse the repository at this point in the history
Optimizing memory usage
  • Loading branch information
roykho committed Nov 10, 2020
2 parents 8db66f7 + c3ba17a commit 4954c17
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes/class-wc-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -1572,10 +1572,15 @@ public static function json_search_products( $term = '', $include_variations = f
$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();

Expand Down

0 comments on commit 4954c17

Please sign in to comment.