| @@ -70,10 +70,17 @@ | ||
| 70 | 70 | |
| 71 | 71 | // Slice the category array to start from the last synced category index |
| 72 | 72 | if ( ! empty( $categories ) ) { |
| 73 | 73 | foreach ( $categories as $category_index => $category_id ) { |
| 74 | + // get last backed up page number for particular category Id. | |
| 75 | + // And start syncing from the last synced page. | |
| 76 | + // If no page number available, it will start from zero. | |
| 77 | + $last_synced_page = get_option( 'cmbird_group_item_sync_page_cat_id_' . $category_id ); | |
| 78 | + if ( ! intval( $last_synced_page ) ) { | |
| 79 | + $last_synced_page = 1; | |
| 80 | + } | |
| 74 | 81 | $data = array( |
| 75 | - 'page' => 1, | |
| 82 | + 'page' => $last_synced_page, | |
| 76 | 83 | 'category' => $category_id, |
| 77 | 84 | ); |
| 78 | 85 | $existing_schedule = as_has_scheduled_action( 'import_group_items_cron', $data ); |
| 79 | 86 | // Schedule the action if it doesn't exist. |
| @@ -123,10 +130,14 @@ | ||
| 123 | 130 | if ( empty( $categories ) ) { |
| 124 | 131 | wp_send_json_error( array( 'message' => __( 'Please select at least one category from cron tab', 'commercebird' ) ) ); |
| 125 | 132 | } else { |
| 126 | 133 | foreach ( $categories as $index => $category_id ) { |
| 134 | + $last_synced_page = get_option( 'cmbird_simple_item_sync_page_cat_id_' . $category_id ); | |
| 135 | + if ( ! intval( $last_synced_page ) ) { | |
| 136 | + $last_synced_page = 1; | |
| 137 | + } | |
| 127 | 138 | $data = array( |
| 128 | - 'page' => 1, | |
| 139 | + 'page' => $last_synced_page, | |
| 129 | 140 | 'category' => $category_id, |
| 130 | 141 | ); |
| 131 | 142 | $existing_schedule = as_has_scheduled_action( 'import_simple_items_cron', $data ); |
| 132 | 143 | if ( ! $existing_schedule ) { |