Skip to content

Commit

Permalink
Merge pull request #7 from justbetter/feature/check-if-product-id-exists
Browse files Browse the repository at this point in the history
Check if product still exists before trying to fetch a customer price
  • Loading branch information
VincentBean authored Mar 1, 2024
2 parents 10f29de + 66dea4f commit 091f258
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Observer/FinalPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public function execute(Observer $observer): void
$customerId = $this->userContext->getUserType() === UserContextInterface::USER_TYPE_CUSTOMER ? (int) $this->userContext->getUserId() : null;
}

if ($customerId === null) {
return;
}

/** @var Product $product */
$product = $observer->getProduct();
$qty = $observer->getQty() ?? 1;

if ($customerId === null || $product->getId() === null) {
return;
}

$price = $this->customerPrice->getCustomerPrice($product->getId(), $customerId, $qty);

if ($price === null) {
Expand Down

0 comments on commit 091f258

Please sign in to comment.