Skip to content

Commit

Permalink
shortend isSaleable observer
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Jun 6, 2022
1 parent 7049086 commit 7563d53
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Observer/Product/IsSaleable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function execute(Observer $observer): void
$saleable = $observer->getData('salable');

if ($product instanceof DataObject && $saleable instanceof DataObject) {
$groupId = $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP);

$isSalable = $saleable->getData('is_salable')
&& $product->getData('can_show_price')
&& $product->getData('is_purchasable');
$isSalable = $isSalable && $groupId !== null ? $this->isSaleable->isSaleable((int) $groupId) : $isSalable;
$isSalable = $isSalable
? $this->isSaleable->isSaleable((int) $this->httpContext->getValue(CustomerContext::CONTEXT_GROUP))
: false;

$saleable->setData('is_salable', $isSalable);
}
Expand Down

0 comments on commit 7563d53

Please sign in to comment.