lizardmedia / product-attachments-magento2

Magento2 module for adding downloadable product attachments
MIT License
40 stars 37 forks source link

Error when saving a product with existing attachment #45

Closed OvalMedia closed 3 years ago

OvalMedia commented 3 years ago

When I try to save a product with an existing attachment I get this error: Item (LizardMedia\ProductAttachment\Model\Attachment) with the same ID "195" already exists.

I cleaned all lizardmedia* tables to be sure everything is from scratch. I also removed all files in pub\media\downloadable\files\attachment.

Then I uploaded a PDF to an existing product which worked fine. But editing this product afterwards failed with the mentioned error.

OvalMedia commented 3 years ago

Sorry, I forgot:

bartoszkubicki commented 3 years ago

@OvalMedia I will look at this this week. Thank you for reporting this issue.

bartoszkubicki commented 3 years ago

@OvalMedia I have reverted change that caused a problem https://github.com/lizardmedia/product-attachments-magento2/commit/676080293bfee87f8655ad372277301170d6c7d5. Please test it

OvalMedia commented 3 years ago

Problem is gone. Thank you.

mmeyran commented 3 years ago

Hello, I'm still getting that error with 1.3.8 - the module allows duplicate pairs of attachment_id and store_id in the title table, and it does happen. I have put a constraint on these columns directly in database to not break my front anymore, and I'm adding checks to my own code to prevent these extra insertion attempts, but it still happens with store_id 0. It would be a good idea to add the constraint to the module itself, though.

mmeyran commented 3 years ago

It seems to happen more often if one tries to save the product through the entity manager.