You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopware 6中sw-entity-multi-select预选后无法搜索产品问题求助

Fix: sw-entity-multi-select can't search/load new products after initial reload in Shopware 6

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 listingCriteria that's bound to sw-entity-multi-select. This lets the component perform unfiltered searches for new products again.
  • Your setProduct method 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 listingCriteria that 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 13:17:57