Skip to content

Commit 091f258

Browse files
authored
Merge pull request #7 from justbetter/feature/check-if-product-id-exists
Check if product still exists before trying to fetch a customer price
2 parents 10f29de + 66dea4f commit 091f258

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Observer/FinalPrice.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public function execute(Observer $observer): void
3838
$customerId = $this->userContext->getUserType() === UserContextInterface::USER_TYPE_CUSTOMER ? (int) $this->userContext->getUserId() : null;
3939
}
4040

41-
if ($customerId === null) {
42-
return;
43-
}
44-
4541
/** @var Product $product */
4642
$product = $observer->getProduct();
4743
$qty = $observer->getQty() ?? 1;
4844

45+
if ($customerId === null || $product->getId() === null) {
46+
return;
47+
}
48+
4949
$price = $this->customerPrice->getCustomerPrice($product->getId(), $customerId, $qty);
5050

5151
if ($price === null) {

0 commit comments

Comments
 (0)