Skip to content

Commit

Permalink
AKM-24: Connector fails because of invalid entities
Browse files Browse the repository at this point in the history
  • Loading branch information
dxops committed Jul 8, 2021
1 parent d40fcff commit 58ee7bd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
8 changes: 3 additions & 5 deletions ImportExport/Strategy/AttributeFamilyImportStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,10 @@ protected function updateRelations($entity, array $itemData = null)
true
);

$key = $relationCollection->indexOf($collectionEntity);
$relationCollection->removeElement($collectionEntity);
if ($existingCollectionEntity) {
if (!$relationCollection->contains($existingCollectionEntity)) {
$relationCollection->removeElement($collectionEntity);
$relationCollection->add($existingCollectionEntity);
}

$relationCollection->set($key, $existingCollectionEntity);
$this->cacheInverseFieldRelation($entityName, $fieldName, $existingCollectionEntity);
}
}
Expand Down
8 changes: 3 additions & 5 deletions ImportExport/Strategy/BrandImportStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,10 @@ protected function updateRelations($entity, array $itemData = null)
true
);

$key = $relationCollection->indexOf($collectionEntity);
$relationCollection->removeElement($collectionEntity);
if ($existingCollectionEntity) {
if (!$relationCollection->contains($existingCollectionEntity)) {
$relationCollection->removeElement($collectionEntity);
$relationCollection->add($existingCollectionEntity);
}

$relationCollection->set($key, $existingCollectionEntity);
$this->cacheInverseFieldRelation($entityName, $fieldName, $existingCollectionEntity);
}
}
Expand Down
8 changes: 3 additions & 5 deletions ImportExport/Strategy/CategoryImportStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,10 @@ protected function updateRelations($entity, array $itemData = null)
true
);

$key = $relationCollection->indexOf($collectionEntity);
$relationCollection->removeElement($collectionEntity);
if ($existingCollectionEntity) {
if (!$relationCollection->contains($existingCollectionEntity)) {
$relationCollection->removeElement($collectionEntity);
$relationCollection->add($existingCollectionEntity);
}

$relationCollection->set($key, $existingCollectionEntity);
$this->cacheInverseFieldRelation($entityName, $fieldName, $existingCollectionEntity);
}
}
Expand Down
8 changes: 3 additions & 5 deletions ImportExport/Strategy/ProductImportStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,10 @@ protected function updateRelations($entity, array $itemData = null)
true
);

$key = $relationCollection->indexOf($collectionEntity);
$relationCollection->removeElement($collectionEntity);
if ($existingCollectionEntity) {
if (!$relationCollection->contains($existingCollectionEntity)) {
$relationCollection->removeElement($collectionEntity);
$relationCollection->add($existingCollectionEntity);
}

$relationCollection->set($key, $existingCollectionEntity);
$this->cacheInverseFieldRelation($entityName, $fieldName, $existingCollectionEntity);
}
}
Expand Down

0 comments on commit 58ee7bd

Please sign in to comment.