Merge pull request woocommerce/woocommerce-admin#2385 from woocommerce/fix/2343-skip_existing-not-importing-all-data

Fix some data not to being imported when 'skip_existing' option is enabled
This commit is contained in:
Paul Sealock 2019-06-13 10:19:56 +12:00 committed by GitHub
commit b76b259d82
1 changed files with 8 additions and 2 deletions

View File

@ -403,7 +403,10 @@ class WC_Admin_Reports_Sync {
);
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 );
@ -653,6 +656,9 @@ class WC_Admin_Reports_Sync {
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,
@ -661,7 +667,7 @@ class WC_Admin_Reports_Sync {
'orderby' => 'ID',
'order' => 'ASC',
'number' => $batch_size,
'paged' => $batch_number,
'paged' => $page,
'role__in' => $customer_roles,
)
);