Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2385 from woocommerce/fix/2343-skip_existing-not-…
Browse files Browse the repository at this point in the history
…importing-all-data

Fix some data not to being imported when 'skip_existing' option is enabled
  • Loading branch information
psealock authored Jun 12, 2019
2 parents db463ab + b43285e commit d1a696b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions includes/class-wc-admin-reports-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ public static function orders_lookup_import_batch( $batch_number, $days, $skip_e
);
self::record_event( 'import_job_start', $properties );

$orders = self::get_orders( $batch_size, $batch_number, $days, $skip_existing );
// When we are skipping already imported orders, the table of orders to import gets smaller in
// every batch, so we want to always import the first page.
$page = $skip_existing ? 1 : $batch_number;
$orders = self::get_orders( $batch_size, $page, $days, $skip_existing );

foreach ( $orders->order_ids as $order_id ) {
self::orders_lookup_import_order( $order_id );
Expand Down Expand Up @@ -653,6 +656,9 @@ public static function customer_lookup_import_batch( $batch_number, $days, $skip
self::record_event( 'import_job_start', $properties );

$customer_roles = apply_filters( 'woocommerce_admin_import_customer_roles', array( 'customer' ) );
// When we are skipping already imported customers, the table of customers to import gets smaller in
// every batch, so we want to always import the first page.
$page = $skip_existing ? 1 : $batch_number;
$customer_query = self::get_user_ids_for_batch(
$days,
$skip_existing,
Expand All @@ -661,7 +667,7 @@ public static function customer_lookup_import_batch( $batch_number, $days, $skip
'orderby' => 'ID',
'order' => 'ASC',
'number' => $batch_size,
'paged' => $batch_number,
'paged' => $page,
'role__in' => $customer_roles,
)
);
Expand Down

0 comments on commit d1a696b

Please sign in to comment.