| Conditions | 6 |
| Paths | 7 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 27 | public function load(Context $context): RuleCollection |
||
| 28 | { |
||
| 29 | $criteria = new Criteria(); |
||
| 30 | $criteria->addSorting(new FieldSorting('priority', FieldSorting::DESCENDING)); |
||
| 31 | $criteria->setLimit(500); |
||
| 32 | $criteria->setTitle('cart-rule-loader::load-rules'); |
||
| 33 | |||
| 34 | $repositoryIterator = new RepositoryIterator($this->repository, $context, $criteria); |
||
| 35 | $rules = new RuleCollection(); |
||
| 36 | while (($result = $repositoryIterator->fetch()) !== null) { |
||
| 37 | foreach ($result->getEntities() as $rule) { |
||
| 38 | if (!$rule->isInvalid() && $rule->getPayload()) { |
||
| 39 | $rules->add($rule); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | if ($result->count() < 500) { |
||
| 43 | break; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | return $rules; |
||
| 48 | } |
||
| 50 |