@@ -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