0

My client needs to produce a Json file with all the latest products, so it can sync with a external site, whenever there are changes in the data -products- it is updated immediately.

They requested to have a daily update with new products, I have never used the REST Api, how can I achieve this?

Also they have mentioned that it could work with a XML file, one named products.xml with all products and a updates.xml file with all the new products that have been added to the site, I'm not sure which solution could be easier to get working.

Could they just feed from the Sitemap.xml ? I appreciate any hints.

0

I don't know if you still need this, but maybe someone else will.

WooCommerce already has a REST API that's very flexible.

For your request you can simply create a API Key and use it to interogate the whole list of products.

Since newest products beeing added with higher ID's they should see the latest products in the feed in real-time (carefull with the requests, it can break your server if you do too many).

Here is how you create the keys in order to authenticate the feed then following this example you can list all the products.

Finally you should have an URL like this: https://example.com/wp-json/wc/v2/products?consumer_key=ck_12345&consumer_secret=cs_98765

The consumer_key and consumer_secret gets replaced with the ones you generated in the Wordpress Admin and the domain changes to yours.

Please do keep in mind that for this to work you need the REST API Enabled WooCommerce > Settings > API, usually this option comes checked by default.

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.