Skip to content

Commit

Permalink
Merge pull request #53 from OXIDprojects/fix-overwriting-multilang-st…
Browse files Browse the repository at this point in the history
…rings-in-oxshops-when-not-present-in-yaml

Prevent overwriting of multilang fields in oxshops when no value is p…
  • Loading branch information
BernhardScheffold authored Sep 18, 2023
2 parents fca52b7 + 48d5895 commit dd0036b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Core/ConfigImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,24 @@ protected function importShopsConfig($aConfigValues)
if ($langId == 0) {
continue;
}
$availableInLangs = $oShop->getAvailableInLangs();
$viewNameGenerator = oxNew(\OxidEsales\Eshop\Core\TableViewNameGenerator::class);
$viewName = $viewNameGenerator->getViewName('oxshops', $langId);
$oShop->setLanguage($langId);
if (isset($availableInLangs[$langId])) {
if (!is_numeric(substr($viewName, 12))) {
$oShop->loadInLang($langId, $sShopId);
foreach ($aOxShopSettings as $sVarName => $mVarValue) {
$iPosUnderscore = strrpos($sVarName, '_');
if ($iPosUnderscore !== false) {
$sStringAfterUnderscore = substr($sVarName, $iPosUnderscore + 1);
if (is_numeric($sStringAfterUnderscore) && $sStringAfterUnderscore == $langId) {
$sFiledName = substr($sVarName, 0, $iPosUnderscore); // String before last underscore
$aOxShopSettings[$sFiledName] = $mVarValue;
}
}
foreach ($aOxShopSettings as $sVarName => $mVarValue) {
$iPosUnderscore = strrpos($sVarName, '_');
if ($iPosUnderscore !== false) {
$sStringAfterUnderscore = substr($sVarName, $iPosUnderscore + 1);
if (is_numeric($sStringAfterUnderscore) && $sStringAfterUnderscore == $langId) {
$sFiledName = substr($sVarName, 0, $iPosUnderscore); // String before last underscore
$aOxShopSettings[$sFiledName] = $mVarValue;
}
}
$oShop->assign($aOxShopSettings);
$oShop->save();
}
$oShop->assign($aOxShopSettings);
$oShop->save();
}
}
}
Expand Down

0 comments on commit dd0036b

Please sign in to comment.