Shopware 6中sw-entity-multi-select预选后无法搜索产品问题求助
Looks like the core issue here is that you're permanently modifying the listingCriteria by setting its IDs to your saved productIds during initialization. Once you do that, the sw-entity-multi-select component will reuse this criteria for all subsequent search requests—so it'll only ever look for products matching those saved IDs, hence the "No result" when trying to find new items.
Here's how to fix this step by step:
1. Use a cloned criteria for loading saved products
Instead of modifying the original listingCriteria (which is bound to the component), create a copy when fetching your saved products. This way, the component's search criteria stays clean for future searches.
Update your getProducts method like this:
getProducts () { this.products = new EntityCollection( this.productRepository.route, this.productRepository.entityName, Context.api ) if (this.productIds.length <= 0) { // Ensure the component's criteria has no ID filters for fresh searches this.listingCriteria.setIds([]); return Promise.resolve() } // Create a copy of the criteria to avoid modifying the one used by the component const loadSavedCriteria = this.listingCriteria.clone(); loadSavedCriteria.setIds(this.productIds); return this.productRepository.search(loadSavedCriteria, Context.api).then((items) => { this.products = items; // Reset the original criteria's ID filter so the component can search all products this.listingCriteria.setIds([]); }) },
2. Why this works
- The cloned criteria (
loadSavedCriteria) is only used to fetch your pre-selected products on reload. - After loading the saved items, we clear the ID filter from the original
listingCriteriathat's bound tosw-entity-multi-select. This lets the component perform unfiltered searches for new products again. - Your
setProductmethod already correctly updates the selected collection and IDs, so that part stays intact.
3. Additional checks
- Make sure you're not adding any other permanent filters to
listingCriteriathat might restrict product visibility. - Since you have over 150k products, relying on
sw-entity-multi-select's built-in pagination and search is the right call—this fix ensures the component can leverage those features without being locked to your saved IDs.
内容的提问来源于stack exchange,提问作者Huzaifa Mustafa

