Skip to content

Commit 89e49b8

Browse files
committed
Merge remote-tracking branch '38433/38384-productrepository-getbyid-cachekey' into community_prs_april
2 parents 4bfee41 + 2aa6cfc commit 89e49b8

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public function get($sku, $editMode = false, $storeId = null, $forceReload = fal
307307
*/
308308
public function getById($productId, $editMode = false, $storeId = null, $forceReload = false)
309309
{
310-
$cacheKey = $this->getCacheKey([$editMode, $storeId]);
310+
$cacheKey = $this->getCacheKey([$editMode, $storeId === null ? $storeId : (int) $storeId]);
311311
if (!isset($this->instancesById[$productId][$cacheKey]) || $forceReload) {
312312
$product = $this->productFactory->create();
313313
if ($editMode) {

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -969,24 +969,13 @@ public function cacheKeyDataProvider(): array
969969
[
970970
'identifier' => 25,
971971
'editMode' => true,
972-
'storeId' => $anyObject
972+
'storeId' => '1'
973973
],
974974
[
975975
'identifier' => 'test-sku',
976976
'editMode' => true,
977-
'storeId' => $anyObject
977+
'storeId' => 1
978978
],
979-
[
980-
'identifier' => 25,
981-
'editMode' => false,
982-
'storeId' => $anyObject
983-
],
984-
[
985-
986-
'identifier' => 'test-sku',
987-
'editMode' => false,
988-
'storeId' => $anyObject
989-
]
990979
];
991980
}
992981

0 commit comments

Comments
 (0)