Shopify: Is it possible to find a product by sku number?

一世执手 提交于 2020-02-01 05:06:08

问题


The data that I'm getting only contains the SKU numbers. I am trying to figure out how I can link these SKU numbers to the product variants in Shopify without the actual product id number.

Example data:

<Inventory ItemNumber="100B3001-B-01">
    <ItemStatus Status="Avail" Quantity="0" />
  </Inventory>
  <Inventory ItemNumber="100B3001-B-02">
    <ItemStatus Status="Avail" Quantity="0" />
  </Inventory>
  <Inventory ItemNumber="100B3001-B-03">
    <ItemStatus Status="Avail" Quantity="-1" />
    <ItemStatus Status="Alloc" Quantity="1" />
  </Inventory>
  <Inventory ItemNumber="100B3001-B-04">
    <ItemStatus Status="Avail" Quantity="-1" />
    <ItemStatus Status="Alloc" Quantity="1" />
  </Inventory>

回答1:


Here's a delightful, condescending discussion from Shopify employees in 2011 asking why you can't just store the Shopify ID everywhere. The "stock-keeping unit" is a universal systems integration point and, in every system I've seen, each SKU uniquely maps to a product because words have meaning, but apparently not at Shopify.

Three years later, you seem to have two options.

One is to create a Fulfillment Service and provide a URL where Shopify will call you asking for stock levels on a SKU; this is probably the simplest solution, provided you have a Web server sitting somewhere where you can expose such a callback.

The second is to periodically page through all of the Products and store a mapping of the Shopify ID to a SKU somewhere, consulting your map when you need to do an update. Because most of our integrations are cron jobs and I'd like to keep them that way, I periodically ask for the products that have changed since the last run, and then update my mapping.




回答2:


As David Lazar points out in his comment, the ability to find a product based on its SKU is not currently supported in the Shopify API.




回答3:


EDIT: This is an unreliable option that I once used as a last resort. I wouldn't recommend using this but I will leave it here in case as someone may find it helpful.

You can use this API endpoint:

/admin/products/search.json?query=sku:abc123

I have only used it in the browser though, and I can't find any documentation for it. And it may stop working at any time.




回答4:


You can use

*.myshopify.com/search?view=json&q=sku:SKUID


来源:https://stackoverflow.com/questions/14326640/shopify-is-it-possible-to-find-a-product-by-sku-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!