Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG, EC] Followup Data Hub Data Importer does not respect overwrite flags for Key mappings #426

Open
wants to merge 9 commits into
base: 1.9
Choose a base branch
from
14 changes: 11 additions & 3 deletions src/Mapping/DataTarget/Direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,20 @@ protected function checkAssignData($newData, $valueContainer, $getter)
$fieldName = $fieldNameParts[2];
}

$fieldDefinition = $this->getFieldDefinition($valueContainer, $fieldName);
if ($this->writeIfTargetIsNotEmpty === false && !$fieldDefinition->isEmpty($currentData)) {
try {
$fieldDefinition = $this->getFieldDefinition($valueContainer, $fieldName);
$currentDataIsEmpty = $fieldDefinition->isEmpty($currentData);
$newDataIsEmpty = $fieldDefinition->isEmpty($newData);
} catch (InvalidConfigurationException $e) {
$currentDataIsEmpty = empty($currentData);
$newDataIsEmpty = empty($newData);
}
kingjia90 marked this conversation as resolved.
Show resolved Hide resolved

if ($this->writeIfTargetIsNotEmpty === false && !$currentDataIsEmpty) {
return false;
}

if ($this->writeIfSourceIsEmpty === false && $fieldDefinition->isEmpty($newData)) {
if ($this->writeIfSourceIsEmpty === false && $newDataIsEmpty) {
return false;
}

Expand Down
Loading