Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bulk update of metafields? #419

Closed
jagthedrummer opened this issue Feb 28, 2018 · 8 comments
Closed

Support for bulk update of metafields? #419

jagthedrummer opened this issue Feb 28, 2018 · 8 comments
Labels
docs pre-v10 Issue opened prior to release of v10 of library Stale

Comments

@jagthedrummer
Copy link

jagthedrummer commented Feb 28, 2018

The main API docs indicate that it's possible to set multiple metafields on a product with a single API call by including them as part of a product update. Is there anyway to do this through the ruby API?

https://help.shopify.com/api/reference/product#update

@wakproductions
Copy link

Not working for me either...

@wakproductions
Copy link

I've got a product like this:

v = ShopifyAPI::Variant.find(7760165896236)
v.metafield=[{namespace: 'product', key: 'product_id', value: '12345xyz', value_type: 'string'}]
v.save
#=> true

v = ShopifyAPI::Variant.find(7760165896236)

### v does not contain the metafield

@travishaynes
Copy link
Contributor

@wakproductions Does this still happen if you fix the typo you have for v.metafield? It should be plural: v.metafields. If that doesn't work, I would try using a ShopifyAPI::Metafield instance in the array instead of a Hash.

@jagthedrummer
Copy link
Author

jagthedrummer commented May 6, 2018

Fixing the typo and using the ShopifyAPI::Metafield class doesn't work either.

2.4.1 :010 > shopify_shop.metafields = [
  ShopifyAPI::Metafield.new({ namespace: 'my-app', value: 'hi', key: 'hello', value_type: 'string'})
]
 => [#<ShopifyAPI::Metafield:0x007fd91a3b9bb0 @attributes={...}, @prefix_options={}, @persisted=false>] 
2.4.1 :011 > shopify_shop.save
ActiveResource::ClientError: Failed.  Response code = 406.  Response message = Not Acceptable.
	from (irb):11

@wakproductions
Copy link

@travishaynes I made the correction you suggested and it now seems to work. Thanks!

@jagthedrummer I don't think you need to enclose it in a ShopifyAPI::Metafield.new... just make it the hash: shopify_shop.metafields = [{ namespace: 'my-app', value: 'hi', key: 'hello', value_type: 'string'}]

@onedanshow
Copy link

You can also bulk add metafields this way:

product = ShopifyAPI::Product.find(12341234)
product.update_attributes(metafields: [{ namespace: 'test', key: 'test', value: 1, value_type: 'integer' }])

Updating / overriding does not work this way, though.

@nwtn nwtn added the docs label May 27, 2019
@mkevinosullivan mkevinosullivan added the pre-v10 Issue opened prior to release of v10 of library label Mar 9, 2022
@github-actions
Copy link

github-actions bot commented Oct 8, 2022

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

@github-actions github-actions bot added the Stale label Oct 8, 2022
@github-actions
Copy link

We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pre-v10 Issue opened prior to release of v10 of library Stale
Projects
None yet
Development

No branches or pull requests

6 participants