Skip to content

Commit

Permalink
Fix a bug that it would never run the delete batch requests
Browse files Browse the repository at this point in the history
There are two problems:
1. `$product_id_map` is an array map with the format like
	 `[ 'online:en:TW:gla_5981' => 5981 ]` while the method
	 `find_delete_product_ids` accepts an array of product IDs.
2. Even though we fix the above issue by using `array_values(
	 $product_id_map)`, WCProductQuery couldn't get the product as well
	 because the product is already trashed.
  • Loading branch information
ianlin committed Nov 14, 2022
1 parent 2d9c4a3 commit 7dfd462
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/Jobs/DeleteProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public function get_name(): string {
* @throws ProductSyncerException If an error occurs. The exception will be logged by ActionScheduler.
*/
public function process_items( array $product_id_map ) {
$ready_ids = $this->product_repository->find_delete_product_ids( $product_id_map );

// Exclude any ID's which are not ready to delete.
$product_id_map = array_intersect( $product_id_map, $ready_ids );

$product_entries = BatchProductIDRequestEntry::create_from_id_map( new ProductIDMap( $product_id_map ) );
$this->product_syncer->delete_by_batch_requests( $product_entries );
}
Expand Down

0 comments on commit 7dfd462

Please sign in to comment.