Skip to content

Commit d9282d8

Browse files
#22933: Apply suggestions from code review
Co-Authored-By: Ihor Sviziev <ihor-sviziev@users.noreply.github.com>
1 parent 70a3adf commit d9282d8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public function save(ProductInterface $product, $saveOptions = false)
574574
);
575575
}
576576
$this->removeProductFromLocalCacheBySku($product->getSku());
577-
unset($this->instancesById[$product->getId()]);
577+
$this->removeProductFromLocalCacheById($product->getId());
578578

579579
return $this->get($product->getSku(), false, $product->getStoreId());
580580
}
@@ -588,7 +588,7 @@ public function delete(ProductInterface $product)
588588
$productId = $product->getId();
589589
try {
590590
$this->removeProductFromLocalCacheBySku($product->getSku());
591-
unset($this->instancesById[$product->getId()]);
591+
$this->removeProductFromLocalCacheById($product->getId());
592592
$this->resourceModel->delete($product);
593593
} catch (ValidatorException $e) {
594594
throw new CouldNotSaveException(__($e->getMessage()), $e);
@@ -599,7 +599,7 @@ public function delete(ProductInterface $product)
599599
);
600600
}
601601
$this->removeProductFromLocalCacheBySku($sku);
602-
unset($this->instancesById[$productId]);
602+
$this->removeProductFromLocalCacheById($productId);
603603

604604
return true;
605605
}
@@ -770,10 +770,10 @@ private function removeProductFromLocalCacheBySku(string $sku): void
770770
/**
771771
* Removes product in the local cache by id.
772772
*
773-
* @param string $id
773+
* @param string|null $id
774774
* @return void
775775
*/
776-
private function removeProductFromLocalCacheById(string $id): void
776+
private function removeProductFromLocalCacheById(?string $id): void
777777
{
778778
unset($this->instancesById[$id]);
779779
}
@@ -815,7 +815,7 @@ private function saveProduct($product): void
815815
{
816816
try {
817817
$this->removeProductFromLocalCacheBySku($product->getSku());
818-
unset($this->instancesById[$product->getId()]);
818+
$this->removeProductFromLocalCacheById($product->getId());
819819
$this->resourceModel->save($product);
820820
} catch (ConnectionException $exception) {
821821
throw new TemporaryCouldNotSaveException(

0 commit comments

Comments
 (0)