Skip to content

Commit

Permalink
Fix internal server error on missing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Oct 2, 2024
1 parent 4e941f5 commit 312b819
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Model/Resolver/Quote/Data/SalesRuleLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\SalesRule\Api\Data\RuleInterface;
use Magento\Quote\Model\Quote\Item;
use Magento\GraphQl\Model\Query\Context;
use Magento\Framework\Exception\NoSuchEntityException;

class SalesRuleLabel implements ResolverInterface
{
Expand All @@ -25,8 +26,12 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$labels = [];

foreach (explode(',', (string) $cartItem->getAppliedRuleIds()) as $key=>$ruleId) {
/** @var RuleInterface $rule */
$rule = $this->ruleRepository->getById((int) $ruleId);
try {
/** @var RuleInterface $rule */
$rule = $this->ruleRepository->getById((int) $ruleId);
} catch (NoSuchEntityException) {
continue;
}

// @phpstan-ignore-next-line
$store = $context->getExtensionAttributes()->getStore();
Expand All @@ -51,4 +56,4 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value

return $labels;
}
}
}

0 comments on commit 312b819

Please sign in to comment.