1

An external utility needs to retrieve products from Magento by SKU--either one at a time or in batches, ideally returning the product with all attribute values, photo URLs, categories, etc.

So far I haven't found a direct, simple reference for doing a "hello world" product query against one of the stock APIs--so even that would be useful. Or, given the need to retrieve a "full" product would I just be better served writing my own endpoint to retrieve and serve the required info?

2

None of Magento APIs provide access to "full" product. Using REST API would be easier so go for it if it does not matter. Your application needs to authenticate as an admin user (not customer), see example here.

Here are APIs that you need with examples (note that SKU should work as well as product ID in :productId place-holder below:

  1. Product by SKU: GET http://magentohost/api/rest/products/:productId
  2. Get product images: GET http://magentohost/api/rest/products/:productId/images
  3. Categories to which this product is assigned: GET http://magentohost/api/rest/products/:productId/categories

To retrieve in batches:

  1. Use products list (it has default limits and supports paging so you can get items in chunks): GET http://magentohost/api/rest/products
  2. Iterate through this list and extract details of each individual product as described above

Of course you may implement custom API for single product, but it would be pretty complex and slow. If number of calls is not that critical, better to use existing APIs.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.