Skip to content

Conversation

@malinajirka
Copy link
Contributor

@malinajirka malinajirka commented Oct 24, 2025

Fixes WOOMOB-1551

Description

This PR ensures that trashed products and variations are properly handled during catalog synchronization. When products or variations are trashed in the backend, they now correctly disappear from the local catalog after both incremental and full sync operations.

The implementation adds support for fetching trashed products and variations during sync operations by including the status=trash parameter in API requests. This allows the app to identify and remove trashed items from the local database.

Testing information

To test this implementation:

  1. Setup: Ensure you have a store with Woo POS local catalog enabled
  2. Test trashed products:
    • Add some products to your store
    • Open the POS app and wait for sync to complete
    • Verify products appear in the catalog
    • Trash one or more products in the WP Admin
    • Trigger an incremental sync in the app (pull to refresh or wait for automatic sync)
    • Verify trashed products no longer appear in the catalog
  3. Test trashed variations:
    • Create a variable product with multiple variations
    • Sync the POS app and verify variations appear
    • Trash one or more variations in WP Admin
    • Trigger sync in the app
    • Verify trashed variations no longer appear when viewing the product
  4. Test full sync:
    • Trash multiple products/variations
    • Trigger full sync in the POS settings
    • Verify only non-trashed items appear after sync completes

Images/gif

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@dangermattic
Copy link
Collaborator

2 Errors
🚫 PR requires at least one label.
🚫 PR is not assigned to a milestone.

Generated by 🚫 Danger

@malinajirka malinajirka marked this pull request as draft October 24, 2025 18:01
@malinajirka malinajirka requested a review from Copilot October 24, 2025 18:02
@malinajirka malinajirka added this to the 23.6 milestone Oct 24, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that products and variations with "trash" status are properly removed from the local catalog during incremental sync operations. The implementation adds support for fetching trashed items via API and upserting them to trigger proper deletion through the database's upsert mechanism.

Key changes:

  • Added includeStatus parameter to product and variation fetch APIs to support filtering by status (including trash)
  • During incremental sync, fetches trashed items separately and includes them in the upsert operation
  • Full sync continues to exclude trash items since they're removed by deleting all local data first

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
WooPosLocalCatalogStore.kt Added includeStatus parameter to fetch methods to enable status-based filtering
WooPosProductRestClient.kt Implemented API parameter handling for include_status in product and variation requests
WooPosSyncVariationsAction.kt Added logic to fetch trashed variations during incremental sync and include them in upsert
WooPosSyncProductsAction.kt Added logic to fetch trashed products during incremental sync and include them in upsert
WooPosSyncVariationsActionTest.kt Added test coverage for trash variation fetching behavior
WooPosSyncProductsActionTest.kt Added test coverage for trash product fetching behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)
}

return trashVariations.toList()
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toList() call is unnecessary since trashVariations is already a MutableList<WooPosVariationEntity>, which is a subtype of List. The method can directly return trashVariations.

Suggested change
return trashVariations.toList()
return trashVariations

Copilot uses AI. Check for mistakes.
)
}

return trashProducts.toList()
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toList() call is unnecessary since trashProducts is already a MutableList<WooPosProductEntity>, which is a subtype of List. The method can directly return trashProducts.

Suggested change
return trashProducts.toList()
return trashProducts

Copilot uses AI. Check for mistakes.
@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitcfc9e6c
Direct Downloadwoocommerce-wear-prototype-build-pr14822-cfc9e6c.apk

@wpmobilebot
Copy link
Collaborator

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitcfc9e6c
Direct Downloadwoocommerce-prototype-build-pr14822-cfc9e6c.apk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants