Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello everybody, we currently facing an issue when deleting an image from an abstract product image

UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet
edited November 2021 in Help

Hello everybody,
we currently facing an issue when deleting an image from an abstract product image set.
When we delete a single image, there is a message on the publish queue which looks like the following

  "listenerClassName": "Spryker\\Zed\\ProductImageStorage\\Communication\\Plugin\\Event\\Listener\\ProductAbstractImageStorageUnpublishListener",
  "transferClassName": "Generated\\Shared\\Transfer\\EventEntityTransfer",
  "transferData": {
    "id": 12573,
    "event": "Entity.spy_product_image.delete",
    "name": "spy_product_image",
    "foreign_keys": [],
    "modified_columns": [],
    "original_values": [],
    "additional_values": []
  "eventName": "Entity.spy_product_image.delete"

Looking at the corresponding listener that should proceed the message, we find the following logic

    public function handleBulk(array $eventEntityTransfers, $eventName)
        $productImageIds = $this->getFactory()->getEventBehaviorFacade()->getEventTransferIds($eventEntityTransfers);
        $productAbstractIds = $this->getQueryContainer()->queryProductAbstractIdsByProductImageIds($productImageIds)->find()->getData();


We are wondering if this can really work for the delete event as implemented in the EventSubscriber

    protected function addProductAbstractImageDeleteStorageListener(EventCollectionInterface $eventCollection)
        $eventCollection->addListenerQueued(ProductImageEvents::ENTITY_SPY_PRODUCT_IMAGE_DELETE, new ProductAbstractImageStorageUnpublishListener(), 0, null, $this->getConfig()->getProductImageAbstractEventQueueName());

The problem: In case of delete, the retrieval of the product abstract ids will not work since it was already deleted from the database at this point. The method will return no result and therefore no delete for storage will follow. For unpublish (the entity still exists) it will work. But for delete at least in our opinion it will not work or do we miss something?

Best regards


    UPWG9AYH2 Posts: 509 🧑🏻‍🚀 - Cadet

    One thing we also do not understand:
    When a single image from a image set gets deleted, according to

    $eventCollection->addListenerQueued(ProductImageEvents::ENTITY_SPY_PRODUCT_IMAGE_DELETE, new ProductAbstractImageStorageUnpublishListener(), 0, null, $this->getConfig()->getProductImageAbstractEventQueueName());

    the logic of the ProductAbstractImageStorageUnpublishListener


    is executed and with this, EVERY image of the related abstract product will be unpublished too.
    Is this really correct?