WooCommerce-REST-API-Client-Library icon indicating copy to clipboard operation
WooCommerce-REST-API-Client-Library copied to clipboard

Creating/Editing/Deleting with an Array

Open psasser opened this issue 10 years ago • 6 comments

Hello hello,

This isn't really an issue, but more of a question. Right now I'm utilizing the product creation/editing/deleting code inside of a loop. I'm doing this to make one API full of products communicate with WooCommerce. The problem is that I might be creating literally hundreds (even up to a thousand) products. When I do this it usually times out. What I've found is that I can create about a hundred products at a time. So I was wondering if there was a way instead of creating one product at a time to instead basically pass an array of products and create them all at once. The hitch in the system comes from using the Rest-API library here to create products, which I know because the other API returns the hundreds of products to me in a second and it won't timeout if I get rid of the product creation code. Any thoughts or suggestions? By the way love this API library that you guys have created.

Thanks, patrick

psasser avatar Jul 31 '15 13:07 psasser

@kloon any update on this issues.

ravibarnwal avatar Jul 27 '16 07:07 ravibarnwal

Did you find any solution to the above issue?

ravibarnwal avatar Nov 05 '16 15:11 ravibarnwal

There was actually a lot going on here. Yes I did ultimately figure out how to create via an Array. I can send you the email thread that I had with Max Rice the creator of the API if you are interested. However it didn't really work out all that well. Also I switched away from this PHP wrapper and moved to this one https://github.com/woocommerce/wc-api-php as it was newer, updated and maintained regularly.

However ultimately when I did switch to using an Array I still got a timeout issue. So the short of what I ended up doing was to ...

  • Generate a big array of products to create
  • Loop through the array one product at a time via AJAX
  • Create one product at a time via an AJAX request so that there was no timeout

I'd be glad to share some code with you if you wanted to take a look. Just let me know.

psasser avatar Nov 09 '16 15:11 psasser

Thank you for response. Yes I need to figure out the issues. So please send me the details/doc/code whichever helpful for me. Also send me the code of using ajax.

ravibarnwal avatar Nov 09 '16 16:11 ravibarnwal

It will take me a while to gather some things up. What email address should I send them to?

psasser avatar Nov 09 '16 16:11 psasser

I sent you a test mail on your github email id.

ravibarnwal avatar Nov 09 '16 16:11 ravibarnwal