0

I am using the extension Amasty Product Attachments. If I add an attachment to a product and then delete that attachment from Amasty -> Product Attachments -> Attachments Management, then I can't open the product in the backend anymore. It just loads forever and I get this error logged into the console:

dynamic-rows.js:660 Uncaught TypeError: dataRecord.slice is not a function
    at UiClass.getChildItems (dynamic-rows.js:660)
    at UiClass.initChildren (dynamic-rows-grid.js:85)
    at UiClass.initialize (dynamic-rows.js:191)
    at UiClass.initialize (wrapper.js:109)
    at UiClass._super (wrapper.js:106)
    at UiClass.initialize (dynamic-rows-grid.js:42)
    at UiClass.initialize (wrapper.js:109)
    at new UiClass (class.js:49)
    at Object.initComponent (layout.js:137)
    at fire (jquery.js:3238)

This is the state if I create a new attachment and assign it to a product:

Table amasty_file:

amasty_file

Table amasty_file_store_product

amasty_file_store_product

If I delete the attachment from Amasty -> Product Attachments -> Attachments Management then the record should get removed in both tables, but it is only getting removed in amasty_file:

Table amasty_file:

amasty_file

Table amasty_file_store_product

amasty_file_store_product

So the product still thinks that it has the attachment, but can't find it since it was deleted, so the error is getting caused.

Normally the file should get deleted in both because of the foreign key constraint, but the constraint does not work as it seems, even though it exists.

Foreign Key Setup in table amasty_file_store_product:

foreign key setup in amasty_file_store_product


If I test it on a fresh magento 2, then it works!

So I disabled all third party modules in my not working environment and changed to the Luma default theme, but it still fails.

I am running on Magento 2.4.2 on both. Tested with PHP 7.4 and PHP 7.3.

The code of the extension in the fresh magento 2 is exactly the same as in my environment.

I hope someone has an idea

0

I figured it out, I had to go to "Relation view". I noticed that the constraint "AMASTY_FILE_STORE_PRODUCT_FILE_ID_AMASTY_FILE_FILE_ID" was missing, so I created it again by looking at a fresh magento with a fresh extension installed.

enter image description here


OLD ANSWER:

I was finally able to solve it, but I have no clue why it worked.

Solution:

  1. Delete all amasty_file* tables.
  2. Open Table "setup_module" and delete entry "Amasty_ProductAttachment"
  3. Execute php bin/magento setup:upgrade to install the tables again.
  4. It should work now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.