View Single Post
  #2  
Old 04-02-2017, 11:27 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Advice with REST API

Quote:
Originally Posted by johngwms
Products
Many products will need attributes defined in XC5 and I would like to keep the master versions of these in ZI. The documentation for the REST API does not mention attributes. Does this mean that product attribute data cannot be transferred via the REST API?

It is possible to retrieve product attributes, but not in a single REST API request.

First, you should get the product information:
https://[YOUR_STIE]/admin.php?target=RESTAPI&_key=[YOUR_KEY]&_path=product/[PRODUCT_ID]

Then you should iterate over product attributes and get information on every product attribute:
https://[YOUR_SITE]/admin.php?target=RESTAPI&_key=[YOUR_KEY]&_path=attribute/[ATTRIBUTE_ID]

Perhaps, you also should run other requests to get information on which attribute options the product has available.

You will end up with a lot requests per product, so it may make sense to customise the REST API module and add a custom API function that will return all the product's attributes in a single request.

Quote:
Originally Posted by johngwms
Sales Orders
When a customer order is placed on XC5, how can the REST API be used to push the order to ZI? Will it be necessary for ZI to poll the REST API to check for a new order instead?

REST API can be used for pull requests only. Yes, you should poll the API to check for new orders.

Quote:
Originally Posted by johngwms
Access to Custom Module
Can the REST API be used to communicate with a Custom Module?

REST API provides an interface to access the database from third-party applications. You can access database records and fields added by a custom module, but you can't communicate with the module's functions directly (all requests translate to methods defined in Model/Repo classes).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote