| Conditions | 2 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function consumeEvent(PostTransformEvent $event): void |
||
| 33 | { |
||
| 34 | $this->buildProperty( |
||
| 35 | $event, |
||
| 36 | ProductInterface::class, |
||
| 37 | function (ProductInterface $product, Document $document): void { |
||
| 38 | $soldUnits = 0; |
||
| 39 | |||
| 40 | foreach ($product->getVariants() as $productVariant) { |
||
| 41 | $soldUnits += $this->orderItemRepository->countByVariant($productVariant); |
||
| 42 | } |
||
| 43 | |||
| 44 | $document->set($this->soldUnitsProperty, $soldUnits); |
||
| 45 | } |
||
| 49 |