From 6cd952dbd7abceb1075d1b30bf1318496cf50416 Mon Sep 17 00:00:00 2001 From: robertsaternus Date: Mon, 13 Jan 2025 13:34:38 +0100 Subject: [PATCH] FFWEB-3284:Export optimization for Schoenberger --- src/Export/ExportProducts.php | 6 +----- src/Export/Field/FilterAttributes.php | 12 ++++-------- src/Resources/config/services.xml | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Export/ExportProducts.php b/src/Export/ExportProducts.php index 1b56b845..7f1f808e 100644 --- a/src/Export/ExportProducts.php +++ b/src/Export/ExportProducts.php @@ -23,7 +23,7 @@ public function __construct(SalesChannelRepository $productRepository, array $cu $this->customAssociations = $customAssociations; } - public function getByContext(SalesChannelContext $context, int $batchSize = 100): iterable + public function getByContext(SalesChannelContext $context, int $batchSize = 1): iterable { $criteria = $this->getCriteria($batchSize); $products = $this->productRepository->search($criteria, $context); @@ -46,7 +46,6 @@ private function getCriteria(int $batchSize): Criteria $criteria->addAssociation('categories'); $criteria->addAssociation('categoriesRo'); $criteria->addAssociation('children.options.group'); - $criteria->addAssociation('children.properties.group'); $criteria->addAssociation('manufacturer'); $criteria->addAssociation('properties'); $criteria->addAssociation('customFields'); @@ -58,9 +57,6 @@ private function getCriteria(int $batchSize): Criteria } $criteria->addFilter(new EqualsFilter('parentId', null)); - $criteria->getAssociation('children') - ->addFilter(new EqualsFilter('active', true)); - return $criteria; } } diff --git a/src/Export/Field/FilterAttributes.php b/src/Export/Field/FilterAttributes.php index c92cec4c..f58e4269 100644 --- a/src/Export/Field/FilterAttributes.php +++ b/src/Export/Field/FilterAttributes.php @@ -34,14 +34,10 @@ public function getName(): string */ public function getValue(Entity $entity): string { - $attributes = array_map($this->propertyFormatter, $this->applyPropertyGroupsFilter($entity)); - - if ($entity->getChildren()) { - $attributes = $entity->getChildren()->reduce( - fn (array $result, Product $child): array => $result + array_map($this->propertyFormatter, $child->getOptions()->getElements()), - $attributes - ); - } + $attributes = $entity->getChildren()->reduce( + fn (array $result, Product $child): array => $result + array_map($this->propertyFormatter, $child->getOptions()->getElements()), + array_map($this->propertyFormatter, $this->applyPropertyGroupsFilter($entity)) + ); return $attributes ? '|' . implode('|', array_values($attributes)) . '|' : ''; } diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index a35b8cd4..c144065e 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -134,7 +134,6 @@ -