Ecommerce Shopify WordPress Discussion

How to decrease latency when getting product.metafields through the shopify Ruby gem?

Consider the following lines that interacts with the shopify Ruby gem. First we fetch a bunch of products through Shopify's REST API. products = ShopifyAPI::Product.find(:all, :params => {}) product = products.first Then we try getting the metafields of a product. puts Benchmark.measure { 100.times { |s| product.metafields } } # => 0.375952 0.083343 0.459295 ( 26.157793) Any idea why getting metafields takes this long time? As far as I understand they are part of the product object and does not require a separate API request.
Forget using Rest API for this. Instead, switch to GraphQL. Like magic, your product query can now ask for and extract metafields. Wonderful! What progress! Use RestAPI only when you need basic information not otherwise serviced by GraphQL as they are not at parity.

December 30, 2023

Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.