Conditions | 2 |
Paths | 1 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
45 | public function consumeEvent(TransformEvent $event): void |
||
46 | { |
||
47 | $this->buildProperty($event, ProductInterface::class, |
||
48 | function (ProductInterface $product, Document $document): void { |
||
49 | $soldUnits = 0; |
||
50 | |||
51 | foreach ($product->getVariants() as $productVariant) { |
||
52 | $soldUnits += count($this->orderItemRepository->findBy(['variant' => $productVariant])); |
||
53 | } |
||
54 | |||
55 | $document->set($this->soldUnitsProperty, $soldUnits); |
||
56 | } |
||
60 |