I'm importing products in bulk. I followed the tutorial at https://devdocs.magento.com/guides/v2.3/rest/tutorials/bulk-configurable-product/config-product-intro.html with our own data.
My scenario is to create the configurable product with all its simple products, then add configurable options and join these simple products with the configurable. Basically, step 2 and 3 from the tutorial.
Everything is running good. I have the RabbitMQ installed and bin/magento queue:consumers:start async.operations.all running. I run it manually.
After the first import, I deleted all the products and reimported them (while async.operations.all console script was still running). The products were created, also the configurable options, but when linking the products, I found this error in magento_operation table "The product was unable to be saved. Please try again."
I set up some logs and I found out this is the problem.
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (catalog_product_super_attribute
, CONSTRAINT CAT_PRD_SPR_ATTR_PRD_ID_CAT_PRD_ENTT_ENTT_ID
FOREIGN KEY (product_id
) REFERENCES catalog_product_entity
(entity), query was: INSERT INTO
catalog_product_super_attribute (
product_id,
attribute_id,
position`) VALUES (?, ?, ?)
The problem is that, somehow, the console script thinks the old (deleted) product still exists (in memory???) and is trying to add the old product id in this table, resulting in this error.
When I terminate the console script and start it again, and after deleting the product, everything runs good again.
So my question is. How do I tell Magento to restart this script when I delete a product from admin? Or is there some other way?
I tried to create an observer on "catalog_product_delete_after_done" event with
$this->_pillPut->put() ($this->_pullPut being \Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface), but that doesn't work.
Any help is appreciated.