From 537a850c8ced3ec6595d8bc2b442e5bccab72e64 Mon Sep 17 00:00:00 2001 From: ResidentEvilEnjoyer <152894096+ResidentEvilEnjoyer@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:05:42 +0300 Subject: [PATCH 1/2] Search for interface instead of class When you extend product entity product class name changes. To solve this use interfaces. --- .../EventSubscriber/TimestampableSubscriber.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php b/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php index 553eb6492de6..053c466dc8a5 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)); + } } From 27266223fc5c6cf6360a2d9d23bc9874b04b950a Mon Sep 17 00:00:00 2001 From: ResidentEvilEnjoyer <152894096+ResidentEvilEnjoyer@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:10:48 +0300 Subject: [PATCH 2/2] Update TimestampableSubscriber.php --- .../EventSubscriber/TimestampableSubscriber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php b/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php index 053c466dc8a5..6381fcd8746f 100644 --- a/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php +++ b/src/Akeneo/Tool/Bundle/VersioningBundle/EventSubscriber/TimestampableSubscriber.php @@ -73,6 +73,6 @@ public function prePersist(LifecycleEventArgs $args) private function isProduct(string $resourceName): bool { - return in_array(ProductInterface::class, class_implements($resourceName)); + return in_array(ProductInterface::class, class_implements($resourceName) ?? []); } }