I need to set 10,000+ product variants to untaxable in Shopify using the shopify_api
Ruby gem.
I have tried:
irb(main):001:0> ShopifyAPI::Variant.update_all(taxable: false)
but I get the error message:
NoMethodError: undefined method `update_all' for ShopifyAPI::Variant:Class
from (irb):1
from /var/lib/gems/2.3.0/gems/shopify_api_console-2.0.0/lib/shopify_api_console/console.rb:156:in `launch_shell'
from /var/lib/gems/2.3.0/gems/shopify_api_console-2.0.0/lib/shopify_api_console/console.rb:113:in `console'
from /var/lib/gems/2.3.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /var/lib/gems/2.3.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /var/lib/gems/2.3.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
from /var/lib/gems/2.3.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from /var/lib/gems/2.3.0/gems/shopify_api_console-2.0.0/bin/shopify-api:4:in `<top (required)>'
from /usr/local/bin/shopify-api:22:in `load'
from /usr/local/bin/shopify-api:22:in `<main>'
3
Answers
You probably need to iterate over a collection. I think this should work, and to avoid api rate limit you can sleep every 1000 calls.
shopify_app
gem usesActive Resource
.You can check its wiki to see what methods are supported (
update_all
is not one of them). As far as I know (but I am relatively new to using Shopify) you can not bulk update 10.000 products. There is inventoryBulkAdjustQuantityAtLocation, but it is for inventory only.You have to make multiple calls and have to mind shopify’s rate limiting.
To update product variants, try this:
As of
2019-10
API version this is how you should paginate results:I think this will update a product with all its variant. Using David’s comment and post.
This code is better…