Creating/Editing/Deleting with an Array
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
@kloon any update on this issues.
Did you find any solution to the above issue?
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.
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.
It will take me a while to gather some things up. What email address should I send them to?
I sent you a test mail on your github email id.