Vendure: Cannot get image url of product from Collection detail

Created on 22 Apr 2021  路  4Comments  路  Source: vendure-ecommerce/vendure

When getting collection detail from api, I want get list of products in that collection. Everything seem good, but the result does not have image url as I expected.

query GetCollectionDetail($id: ID!, $options: ProductVariantListOptions!){ collection(id: $id) { id name productVariants(options: $options) { totalItems items { id sku name price assets { source preview } } } } }

Variables:
{ "id": "3", "options": { "skip": 0, "take": 5 } }

bug 馃悰

All 4 comments

Hi, I cannot reproduce this. Can you provide more details - vendure core version, the response you receive, etc.

Hi @michaelbromley ,

Please take a look in the attached screenshot.
Screen Shot 2021-04-22 at 21 28 04

I've tried on https://demo.vendure.io/shop-api GraphQL playground.
The response as below:

{
  "data": {
    "collection": {
      "id": "3",
      "name": "Computers",
      "productVariants": {
        "totalItems": 25,
        "items": [
          {
            "id": "1",
            "sku": "L2201308",
            "name": "Laptop 13 inch 8GB",
            "price": 129900,
            "assets": []
          },
          {
            "id": "2",
            "sku": "L2201508",
            "name": "Laptop 15 inch 8GB",
            "price": 139900,
            "assets": []
          },
          {
            "id": "3",
            "sku": "L2201316",
            "name": "Laptop 13 inch 16GB",
            "price": 219900,
            "assets": []
          },
          {
            "id": "4",
            "sku": "L2201516",
            "name": "Laptop 15 inch 16GB",
            "price": 229900,
            "assets": []
          },
          {
            "id": "5",
            "sku": "TBL200032",
            "name": "Tablet 32GB",
            "price": 32900,
            "assets": []
          }
        ]
      }
    }
  }
}

This is because those ProductVariants do not have any assets assigned to them. That's why the array is empty. You can try assigning an asset to the Laptop 13 inch 8GB variant and then try again to check.

Thanks @michaelbromley. It worked.

I will close this issue.

Was this page helpful?
0 / 5 - 0 ratings