ElasticSearch plugin: ability to get all Product assets
See original GitHub issueIs your feature request related to a problem? Please describe.
It’s quite common to have more than one asset in product listings (e.g. when your frontend needs switching between two images on hover). So in that case featuredAsset
is not enough. When you store the assets in Product, you want to have access to it from ProductVariant.
For now there is a problem using ElasticsearchPlugin to get product.assets
as the array does’t exist due to not being joined on fetch (see the example below).
customProductMappings: {
secondaryFeaturedAssetPreview: {
graphQlType: 'String',
valueFn: (product) => {
// product.assets doesn't exist
// so you can't return product assets info
},
},
}
Example query for above scenario:
{
search(input: { collectionId: 1, groupByProduct: true }) {
items {
productName
customMappings {
...on CustomProductMappings {
secondaryFeaturedAssetPreview
}
}
}
}
}
Describe the solution you’d like Any ability to get Product assets without making indexing much slower.
Describe alternatives you’ve considered. Actually the case when you use all assets in listings is very rare. Many people need just one more except the featured. So maybe the better way is to add secondary featured asset? But this is not a minimalist approach - basically one featured image is enough.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I can get this
Hi @Izayda The first idea sounds worth exploring. Support for lists in customMappings can be implemented first, and then this feature built on top. I prefer that to the 2nd option, because it is inevitable that people will at some point want to index other relations.