From 52de20c0a46c4612a93930f9abe1c9f7577da72a Mon Sep 17 00:00:00 2001 From: Sander Merks Date: Wed, 7 Sep 2022 13:24:05 +0200 Subject: [PATCH] Now always loading through entityManager to make sure readHandlers are triggered --- .../AbstractStoreLinkedResource.php | 22 +++++++++++++++++++ composer.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Model/ResourceModel/AbstractStoreLinkedResource.php b/Model/ResourceModel/AbstractStoreLinkedResource.php index 3c3cd0d..bd9b5aa 100755 --- a/Model/ResourceModel/AbstractStoreLinkedResource.php +++ b/Model/ResourceModel/AbstractStoreLinkedResource.php @@ -71,6 +71,8 @@ public function lookupStoreIds($id) } /** + * Saving through entityManager to trigger saveHandlers + * * @param AbstractModel $object * @return $this|AbstractStoreLinkedResource */ @@ -81,6 +83,26 @@ public function save(AbstractModel $object) return $this; } + /** + * Loading with entityManager to trigger readHandlers + * + * @param AbstractModel $object + * @param mixed $value + * @param string|null $field + * @return AbstractStoreLinkedResource + */ + public function load(AbstractModel $object, $value, $field = null) + { + if ($field !== null && $field !== $this->getIdFieldName()) { + parent::load($object, $value, $field); + $value = $object->getId() ?? $value; + } + + $object = $this->entityManager->load($object, $value); + + return $this; + } + /** * The name of the main table for the entity which is connected to stores * @return string diff --git a/composer.json b/composer.json index 2e6d3c2..3fabf27 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "weprovide/magento2-core", "description": "", "type": "magento2-module", - "version": "1.2.1", + "version": "1.2.2", "license": "MIT", "authors": [ {