From 5af52fdf88e0b3e0f3d6bbf2c22f8272c0711a81 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 19 Nov 2025 12:48:54 +0100 Subject: [PATCH 1/2] Fix grouped child image bug Fixes a bug with configurable exported child products. This fix makes sure the configurable image is used for the children --- Model/Write/EavIterator.php | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Model/Write/EavIterator.php b/Model/Write/EavIterator.php index 4394984..c0f204c 100644 --- a/Model/Write/EavIterator.php +++ b/Model/Write/EavIterator.php @@ -276,6 +276,7 @@ public function getIterator(): \Traversable $this->setEntityIds($entityIds); if ($this->config->isGroupedExport($this->store) && $this->entityCode === Product::ENTITY) { $this->preloadParentRelations($entityIds); + $this->preloadConfigurableImageData(); } $select = $this->createSelect(); @@ -303,6 +304,7 @@ public function getIterator(): \Traversable isset($this->parentRelations[$result['entity_id']]) ) { $result['parent_id'] = $this->parentRelations[$result['entity_id']]; + $result = $this->setImagesAttributesFromConfigurable($result); } yield $result; @@ -576,4 +578,50 @@ protected function preloadParentRelations(array $productIds): void $this->parentRelations = $connection->fetchPairs($select); } + + /** + * @return void + */ + protected function preloadConfigurableImageData(): void + { + $uniqueConfigurableIds = array_unique($this->parentRelations); + if (empty($uniqueConfigurableIds)) { + return; + } + + $imageAttributes = ['image', 'small_image', 'thumbnail']; + $connection = $this->getConnection(); + $select = $connection->select() + ->from( + ['cpev' => 'catalog_product_entity_varchar'], + ['entity_id' => 'cpev.entity_id', 'value' => 'cpev.value'] + ) + ->join( + ['ea' => 'eav_attribute'], + 'ea.attribute_id = cpev.attribute_id', + ['attribute_code' => 'ea.attribute_code'] + ) + ->where('ea.attribute_code IN (?)', $imageAttributes) + ->where('cpev.entity_id IN (?)', $uniqueConfigurableIds); + + $result = $connection->fetchAll($select); + foreach ($result as $row) { + $this->parentRelationsImageAttributes[$row['entity_id']][$row['attribute_code']] = $row['value']; + } + } + + /** + * @param array $attributes + * + * @return array + */ + protected function setImagesAttributesFromConfigurable(array $attributes): array + { + $parentId = $attributes['parent_id']; + foreach ($this->parentRelationsImageAttributes[$parentId] ?? [] as $attribute => $attributeValue) { + $attributes[$attribute] = $attributeValue; + } + + return $attributes; + } } From baec20f8cacc08b62df775aa52c9f18a82489c71 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 19 Nov 2025 14:53:04 +0100 Subject: [PATCH 2/2] Add property Add property --- Model/Write/EavIterator.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Model/Write/EavIterator.php b/Model/Write/EavIterator.php index c0f204c..8fc1fb4 100644 --- a/Model/Write/EavIterator.php +++ b/Model/Write/EavIterator.php @@ -113,6 +113,11 @@ class EavIterator implements IteratorAggregate */ private array $parentRelations = []; + /** + * @var array + */ + private array $parentRelationsImageAttributes = []; + /** * EavIterator constructor. *