Developer forum

Forum » Integration » "Create product" in PIM fails if EcomProducts has row with ProductID=""

"Create product" in PIM fails if EcomProducts has row with ProductID=""

Jonas Krarup Dam
Reply

Hey, 
I know this is a "you fucked up, you get to suffer" error, but a check or a more informative error would be helpful :-) 

basically, if a product with productID="" exists, any time you try to create a new product, this product is updated, and the UI shows an un-helpful error-message.

Thanks Jonas


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Tries to create a new product from integration - or from the UI?

Which version?

Thanks - we will see if we can fix it.

 
Jonas Krarup Dam
Reply

When I try to create a new product from the UI - I specifically see the exception in 9.17, when I create a new product via PIM. 

The error happens in ProductRepository.Save. When a new product is saved, it still looks for one with ID='' and languageid=CurrentLanguage. I believe there should either be a check if the ID is '', or an "IsNew" flag, that skips the check in DB, so that it would be possible to have a product with productId="" (not that I need to...)

I haven't tested in DW10, but if this bit of code is unchanged, and I'm guessing it is, I would expect the same error :-)

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Yeah, alright.

I made a pull to 'fix' this - but it will mean that you cannot save changes to a product with an empty id.... So empty ID is still not valid - so if you edit a product with empty id it will get saved as a new product.

But - what error do you get?

 
Jonas Krarup Dam
Reply

Hej Nicolai, 

If you prefer adding an informative error message, that's fine too - I don't need to have products with an empty productid :-)

I get this error: 


 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Completely different beast. 

 
Jonas Krarup Dam
Reply

Yeah, the error message makes it look like it's something else entirely, but I debugged into the DW source code to figure out what the problem was. It was caused by the error described above. 

When trying to save a new product, The "afterSave" notification was was sent with "before" and "after" products in the arg set to Null, which caused the error shown above.

 

You must be logged in to post in the forum