Get all metafields for products

Shopify Expert
3943 16 330

As I told you. Asking for metafields by using some generic resource owner like "product" is chaos. There is little to no chance Shopify would support that as an ad-hoc query as it is expensive to gather those resources easily and cheaply. 

So function in the normal way. Get your products of interest first, and then get their metafields. It is not complex and it is guaranteed to work.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
1 Like
Tourist
9 0 2

@HunkyBill I know, but doing that would require thouthands of requests. And why would it be difficult to gather the resources? If you are ONLY downloading one type, like products?

In any case, if Shopify dev team is around, I'd like to hear what they say about this.

Improved Google Shopping Feed App: https://apps.shopify.com/simple-google-shopping-feed
0 Likes
Shopify Expert
3943 16 330

Think about the results Dennis. First off. A shop can have zero, one or more products. If there are 10,000 and each has say 100 metafields. You understand? While your abstract thinking is easy, think deeper. If it was necessary or easy, you'd have it. Not having it is a pointer not to Shopify being lazy, but to the problem being just that. A problem. 

You want all metafields for all products. I pointed out to you that that is easy. It might involve a fair number of API calls, but who cares. They are cheap and easy to manage.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Tourist
9 0 2

I don't want to start a war here... but querying 400 times 250 results ALWAYS needs less resources than querying 10000 times 1 result. I'm not talking about grabbing ALL metafields, but metafiels bij owner_resource. Or even by owner_resource/namespace combo.

Improved Google Shopping Feed App: https://apps.shopify.com/simple-google-shopping-feed
1 Like
Shopify Expert
3943 16 330

Computers are governed by math. As you wisely point out. You can request 100,000 products with a mere 400 API calls. Any chump can pull that off. 

So that person now has 100,000 products. And wow... that took all of what, 180 seconds? Holy inconvenience Batman!  Moving on, now that said coder has 100,000 products to play with, indeed, getting the Metafields for each one is a chore. Could mean 100,000 more calls right?

So you learn to layer and filter in your API calls, so as to minimize calls. In most cases, it works out fine.

No one wants to start a war. It is just that to move someone along quicker to their goal, we have to point out the way for them to go. And if they feel they don't like it, well, that is what we call tough bananas. At this time, metafields are not a simple resource you can just have, without doing a little extra work.  

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Shopify Partner
660 0 109

Upvoting this. I also need to bulk load meta fields.

0 Likes
New Member
5 0 0

I have many products (100 000 for example). But Shopify doesn't allow to store SKU (why?!?!?!?!?!?!?!?!?!?!) and as result I must store SKU inside metafields and any time I must fetch metafields for any products to check if product available in shop or not. Now I have API calls = products pages count + products count just to read available data. If I have 100 000 products - I must use more than 100 000 calls because I can't use pagination with next parameters:

/admin/metafields.json?metafield[key]=SKU&metafield[owner_resource]=product

Now API have limits: 2 requests per second.

100 000 products / 2 requests / 60 seconds / 60 minutes = 14 HOURS!

During this time my product list can be changed many times.

 

0 Likes
Shopify Expert
9807 91 1557

 But Shopify doesn't allow to store SKU

Sure it does. You store things like SKU code on the variant.

So when creating a product:

POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "variants": [
      {
        "option1": "First",
        "price": "10.00",
        "sku": "123"
      },
      {
        "option1": "Second",
        "price": "20.00",
        "sku": "123"
      }
    ]
  }
}

 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
5 0 0

Product SKU is differ than variants (combinations) SKU and must be saved in other place for products with variants. Surprice!

0 Likes
New Member
5 0 0

Variants count restriction is a problem too. 3 options is aren't enough.

0 Likes