0

I have a shopify store that I want to automatically update the product variants inventory levels with, using a live xml feed from the wholesaler I use.

I'm learning to program (Ruby) and this is my first project, but after researching here is how I think it should work.

Use Ruby/Nokugiri to parse the XML feed from the wholesaler, and then Xpath to locate both the unique product variant SKU code, and the stock level.

Somehow I need to use this SKU to refer back to my Shopify store product XML list, and pull out the variants unique ID using the SKU code.

Then use something like the builder gem to build the XML format that shopify needs, and then use curl to PUT the changes. I'm guessing I loop this process for every product?

I know Shopify only has a 300 call limit, so I've got the article on putting a delay in the script, but I get the feeling the above method isn't the easiest way to go about this?

With Shopify you need to apply the variant stock level update against unique variant xml files, so I need to build the unique xml file/code and PUT it against /admin/variants/#[thevariantid].xml

I'm looking forward to trying to put this together and learning in the process, but am I on the right track with this? Are there simpler gems I should be looking at?

n.b I've only recently started learning Ruby, and will head to Rails afterwards. I know a bit about XML and it's structure so should be ok finding what I need with XPath.

4

2 回答 2

3

您走在正确的轨道上,但我会使用 shopify_api gem 与 Shopify 进行对话,而不必自己形成 XML 和 URI:https ://github.com/Shopify/shopify_api

我们的 wiki 上有一篇文章也可以帮助您了解 API 调用限制,但如果您需要更多空间,请告诉我 - 我们非常灵活,限制实际上只是为了防止脚本变得疯狂和影响为其他所有人服务。

于 2011-01-04T15:31:12.823 回答
0

您提出的路径似乎不错,只是不需要使用“builder” gem,因为 Nokogiri 内置了一些非常好的 XML 构建

于 2011-01-04T15:13:20.770 回答