Update post meta issue
-
Hi all,
I have the following issue regarding the use of update_post_meta. I use the Woocommerce plugin, but the issue is related to the update_post_meta so that is why i’m writing you here.So, i wrote a code that creates products and variations from an external application. every variation is identified by a unique code in the external application that is saved in the postmeta table.
The entire code works like this:
– first imports all product ids and their sku into an array and the unique code of the variation and the corresponding post id into another array.
– then it calls to the external application that returns a list with all variations from the application
– for each variation
1. checks if a product id exists (using the sku) if not then creates a new product and the current external product is added as a variation
2. if a product id exists then we have 2 options
a. if a variation already exists then you update color/size/prices
b. if the variation doesn’t exists then you add a new variation to the product idAll products were created correctly and their variations as well.
My problem is on the update color/size/prices side. When it loops through all external variations, the update_post_meta is not working anymore starting from a certain product, it has no return value and no echo is printed on the screen starting the next variation. Also, no new product/variations cannot be created.
If the code in the update color/size/prices is commented out, the rest of the code is working perfectly. so, i tested separately the update color/size/prices part for each variation from the external application.
here comes the odd part: without using update_post_meta and just echoing something on the screen, everything is good. if I use the update_post_meta then the code is blocking at a certain product. i put a counter in the code and it stops at 11125 (!) but if i start from let’s say the product with the external id = 100 then the counter stops at 11107 and it process the product that a step early was blocking the code.Any idea why this situation appears?
thank you for your support
- The topic ‘Update post meta issue’ is closed to new replies.