diff --git a/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php b/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php index 553eb6492de6..6381fcd8746f 100644 --- a/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php +++ b/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php @@ -2,7 +2,7 @@ namespace Akeneo\Tool\Bundle\VersioningBundle\EventSubscriber; -use Akeneo\Pim\Enrichment\Component\Product\Model\Product; +use Akeneo\Pim\Enrichment\Component\Product\Model\ProductInterface; use Akeneo\Tool\Component\Versioning\Model\TimestampableInterface; use Akeneo\Tool\Component\Versioning\Model\Version; use Doctrine\Common\EventSubscriber; @@ -60,7 +60,7 @@ public function prePersist(LifecycleEventArgs $args) $related = $this->em->find( $version->getResourceName(), - $version->getResourceName() === Product::class ? $version->getResourceUuid() : $version->getResourceId() + $this->isProduct($version->getResourceName()) ? $version->getResourceUuid() : $version->getResourceId() ); if (null === $related) { @@ -70,4 +70,9 @@ public function prePersist(LifecycleEventArgs $args) $related->setUpdated($version->getLoggedAt()); $this->em->getUnitOfWork()->computeChangeSet($metadata, $related); } + + private function isProduct(string $resourceName): bool + { + return in_array(ProductInterface::class, class_implements($resourceName) ?? []); + } }