No prices in variants using graphql with shopify plugin

hello. i’m fetching items from storyblok and have items nested(featured_products) in them which are products from shopify (shopify plugin). Everything seems to be good, got nearly all the data but no prices in variants. Whats the issue here? Thanks!



anyone? its a bug or i miss smth

Hello @baxuu,

that the prices aren’t saved is on purpose because when the prices are being updated very often on the E-Commerce backend side it can happen that they get updated too late on the frontend when they get saved in Storyblok and the cache isn’t invalidated correctly on each change and then fetched from new on the frontend side.

With the product ID that is saved on Storyblok, you can get always the latest data from the E-Commerce backend without the need to consider extra dependencies that could introduce problems like the one mentioned above.

Best regards
Hannes

Hi @Hannes
the problem is that I don’t get the product id from the storyblok. also does not receive handle. I have no idea what the id that the storyblok returns, but I can’t get product from the shopify api using this. the product id has this structure: Example value: "gid://shopify/Product/10079785100"

the one that gets from the storyblok looks like this: id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2~

Additionally, there is also a problem in the storyblokk panel, when we want to create a new product and use the plugin to refer to products that are fetching from shopify- only the first 250 products are fetched and the plugin has no pagination implemented. we can’t get to the rest of the products.

Hello @baxuu,

I’ve got an example from a not yet published code that shows the usage of the provided IDs so you get the product data, price etc:

import Client from 'shopify-buy'

const shopifyClient = Client.buildClient({
  domain: 'your-store.myshopify.com',
  storefrontAccessToken: '',
})

export const fetchShopifyProductData = (productID) => {
  const productTitle = ref(null)
  const productImage = ref(null)
  const productPrice = ref(null)
  const productAvailability = ref(null)

  const fetch = async () => {
    shopifyClient.product.fetch(productID).then((fetchedProduct) => {
      productTitle.value = fetchedProduct.title
      productImage.value = fetchedProduct.images[0].src
      productPrice.value = fetchedProduct.variants[0].price
      productAvailability.value = fetchedProduct.variants[0].available
    })
  }

  fetch()

  return { productTitle, productImage, productPrice, productAvailability }
}

My colleagues are aware of the pagination issue and will work on that. For now, you should be able to search by name to get the products that don’t appear in the 250 listed items.

Best regards
Hannes