Skip to content

Commit

Permalink
Visibility should be sync and show for syncable but not synced products
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlin committed Nov 18, 2022
1 parent 6c84398 commit 40f189a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Product/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ public function find_mc_not_synced_product_ids( int $limit = -1, int $offset = 0
'compare' => '!=',
'value' => SyncStatus::SYNCED,
],
[
'key' => ProductMetaHandler::KEY_VISIBILITY,
'compare' => '=',
'value' => ChannelVisibility::SYNC_AND_SHOW,
],
],
];

Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Product/ProductRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,20 @@ public function test_find_mc_not_synced_product_ids() {

$product_2 = WC_Helper_Product::create_simple_product();
$this->product_meta->update_sync_status( $product_2, SyncStatus::HAS_ERRORS );
$this->product_meta->update_visibility( $product_2, ChannelVisibility::SYNC_AND_SHOW );

$product_3 = WC_Helper_Product::create_simple_product();
$this->product_meta->update_sync_status( $product_3, SyncStatus::HAS_ERRORS );
$this->product_meta->update_visibility( $product_3, ChannelVisibility::DONT_SYNC_AND_SHOW );

WC_Helper_Product::create_simple_product();

$variable_product = WC_Helper_Product::create_variation_product();
$this->product_meta->update_sync_status( $variable_product, SyncStatus::NOT_SYNCED );
$this->product_meta->update_visibility( $variable_product, ChannelVisibility::SYNC_AND_SHOW );
foreach ( $variable_product->get_children() as $variation_id ) {
$this->product_meta->update_sync_status( wc_get_product( $variation_id ), SyncStatus::NOT_SYNCED );
$this->product_meta->update_visibility( wc_get_product( $variation_id ), ChannelVisibility::SYNC_AND_SHOW );
}

$this->assertEqualSets(
Expand Down

0 comments on commit 40f189a

Please sign in to comment.