public function getFromWebserviceImport($value, $object = null, $params = [], $idMapper = null)
{
if ($value) {
$storeData = new Object\Classificationstore();
$storeData->setFieldname($this->getName());
$storeData->setObject($object);
$activeGroupsLocal = [];
$activeGroupsRemote = $value->activeGroups;
if (is_array($activeGroupsRemote)) {
foreach ($activeGroupsRemote as $data) {
$remoteId = $data->id;
$localId = $idMapper->getMappedId("csGroup", $remoteId);
$activeGroupsLocal[$localId] = $localId;
}
}
$storeData->setActiveGroups($activeGroupsLocal);
$groupsRemote = $value->groups;
if (is_array($groupsRemote)) {
foreach ($groupsRemote as $remoteGroupData) {
$remoteGroupId = $remoteGroupData->id;
$localGroupId = $idMapper->getMappedId("csGroup", $remoteGroupId);
$remoteKeys = $remoteGroupData->keys;
$remoteKeys = (array) $remoteKeys;
foreach ($remoteKeys as $language => $keyList) {
foreach ($keyList as $keyData) {
$remoteKeyId = $keyData->id;
$localKeyId = $idMapper->getMappedId("csKey", $remoteKeyId);
$keyConfig = Object\Classificationstore\KeyConfig::getById($localKeyId);
$keyDef = Object\Classificationstore\Service::getFieldDefinitionFromJson(json_decode($keyConfig->getDefinition()), $keyConfig->getType());
$value = $keyData->value;
$value = $keyDef->getFromWebserviceImport($value, $object, []);
$storeData->setLocalizedKeyValue($localGroupId, $localKeyId, $value, $language);
}
}
}
}
return $storeData;
}
}