storefront-qwik-starter icon indicating copy to clipboard operation
storefront-qwik-starter copied to clipboard

Issue with Product Display after installing Vendure ElasticSearchPlugin

Open ashishkpaul opened this issue 1 year ago • 5 comments

Hi @gioboa, On Verndure v2.1.9 or v2.2.0 server side, I disable defaultSearchPlugin, then configure ElasticSearchPlugin with basic config options as:

ElasticsearchPlugin.init({
    host: 'http://localhost',
    port: 9200,
    bufferUpdates: false,
}),

then re-index the products, and it's displaying only 10 products from either root or child collections, instead of showing the total list of products present in a collection on the storefront.

GQL query:

query GetProductsInCollections {
    collections {
        items {                
            name
            slug
            parent {
                name
            }
            productVariants {
                totalItems
            }
        }
    }
}

The result is:

{
  "data": {
    "collections": {
      "items": [
        {
          "name": "Electronics",
          "slug": "electronics",
          "parent": {
            "name": "__root_collection__"
          },
          "productVariants": {
            "totalItems": 34
          }
        },
        {
          "name": "Computers",
          "slug": "computers",
          "parent": {
            "name": "Electronics"
          },
          "productVariants": {
            "totalItems": 25
          }
        },
        {
          "name": "Furniture",
          "slug": "furniture",
          "parent": {
            "name": "Home & Garden"
          },
          "productVariants": {
            "totalItems": 13
          }
        },
        {
          "name": "Equipment",
          "slug": "equipment",
          "parent": {
            "name": "Sports & Outdoor"
          },
          "productVariants": {
            "totalItems": 8
          }
        },
        {
          "name": "Camera & Photo",
          "slug": "camera-photo",
          "parent": {
            "name": "Electronics"
          },
          "productVariants": {
            "totalItems": 9
          }
        },
        {
          "name": "Home & Garden",
          "slug": "home-garden",
          "parent": {
            "name": "__root_collection__"
          },
          "productVariants": {
            "totalItems": 22
          }
        },
        {
          "name": "Plants",
          "slug": "plants",
          "parent": {
            "name": "Home & Garden"
          },
          "productVariants": {
            "totalItems": 9
          }
        },
        {
          "name": "Footwear",
          "slug": "footwear",
          "parent": {
            "name": "Sports & Outdoor"
          },
          "productVariants": {
            "totalItems": 24
          }
        },
        {
          "name": "Sports & Outdoor",
          "slug": "sports-outdoor",
          "parent": {
            "name": "__root_collection__"
          },
          "productVariants": {
            "totalItems": 32
          }
        }
      ]
    }
  }
}

ashishkpaul avatar Apr 16 '24 14:04 ashishkpaul

Both server and storefront are fresh installed

ashishkpaul avatar Apr 16 '24 15:04 ashishkpaul

Hi @gioboa,

I've cross-verified with the Remix storefront. With the same setup, all products in a collection are displaying in Remix, but not in Qwik storefront. Thanks for your assistance in advance.

See this video for reference

ashishkpaul avatar Apr 18 '24 07:04 ashishkpaul

Vendure features are a bit out of my knowledge. I tag @michaelbromley, for sure he will have a good answer

gioboa avatar Apr 18 '24 08:04 gioboa

Hi @ashishkpaul I think this may be because the Elasticsearch plugin defaults to take: 10 if no explicit take argument is passed to the search query:

https://github.com/vendure-ecommerce/vendure/blob/0441a0338aeb7742012e24594feb67935d09b2fc/packages/elasticsearch-plugin/src/build-elastic-body.ts#L136

michaelbromley avatar Apr 18 '24 08:04 michaelbromley

Basically, in qwik storefront, needs to add pagination logic

ashishkpaul avatar Jul 31 '24 08:07 ashishkpaul