cancel
Showing results for 
Search instead for 
Did you mean: 

magento saving duplicate products

magento saving duplicate products

I have a case where I'm creating / updating products that I receive by a webservice in batches of 50. My code logic is very simple in pseudo code

 

if product exists

then

    update

else

   create

 

update: find product by unique id -> change values -> save via repository

create: create product using factory -> change values -> save via repository

 

The above script has a lock which will not allow it to execute at the same time as another instance of it, unless it's taken very long to finish e.g. more than 5 minutes

 

However in certain cases I'm experiencing duplicate products like this

 

66942753-68569500-f052-11e9-8906-7d6539cb87b2

 

You will see this is a very unrealistic scenario because the SKU is exactly the same. However if you try it normally to save a product with the same SKU twice, it will append -1 to the latter's sku.

 

I would like to explore how this is possible but I don't have any ideas where to start. I've tried increasing the time limit for the lock in case it was indeed running twice but in that case I would expect to see a -1 appended to the sku.

 

Any ideas what could cause this?