Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Now always loading through entityManager to make sure readHandlers ar…
Browse files Browse the repository at this point in the history
…e triggered
  • Loading branch information
Sander Merks authored and mischabraam committed Sep 8, 2022
1 parent 64df9ae commit 52de20c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Model/ResourceModel/AbstractStoreLinkedResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public function lookupStoreIds($id)
}

/**
* Saving through entityManager to trigger saveHandlers
*
* @param AbstractModel $object
* @return $this|AbstractStoreLinkedResource
*/
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "weprovide/magento2-core",
"description": "",
"type": "magento2-module",
"version": "1.2.1",
"version": "1.2.2",
"license": "MIT",
"authors": [
{
Expand Down

0 comments on commit 52de20c

Please sign in to comment.