Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e1a3ec9

Browse files
author
Maciej Garycki
committedMar 6, 2024·
OSD-12116:
additional performance improvement
1 parent 24fe110 commit e1a3ec9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

‎ImportExport/Strategy/StrategyRelationsTrait.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,22 @@ protected function updateRelations($entity, array $itemData = null)
6262
} elseif ($this->fieldHelper->isMultipleRelation($field)) {
6363
// multiple relation
6464
$relationCollection = $this->getObjectValue($entity, $fieldName);
65-
if ($relationCollection instanceof Collection) {
65+
if (($relationCollection instanceof Collection) && $relationCollection->count()) {
6666
$collectionItemData = $this->fieldHelper->getItemData($itemData, $fieldName);
67+
$searchContext = $this->generateSearchContextForRelationsUpdate(
68+
$entity,
69+
$entityName,
70+
$fieldName,
71+
$isPersistRelation
72+
);
6773
foreach ($relationCollection as $collectionEntity) {
6874
$entityItemData = $this->fieldHelper->getItemData(array_shift($collectionItemData));
6975
$existingCollectionEntity = $this->processEntity(
7076
$collectionEntity,
7177
$isFullRelation,
7278
$isPersistRelation,
7379
$entityItemData,
74-
$this->generateSearchContextForRelationsUpdate(
75-
$entity,
76-
$entityName,
77-
$fieldName,
78-
$isPersistRelation
79-
),
80+
$searchContext,
8081
true
8182
);
8283

0 commit comments

Comments
 (0)
Please sign in to comment.