|
@@ 292-315 (lines=24) @@
|
| 289 |
|
return $option; |
| 290 |
|
} |
| 291 |
|
|
| 292 |
|
private function addGroupTranslation(Group $group, Product $product) |
| 293 |
|
{ |
| 294 |
|
/** @var \Shopware\Connect\Struct\Translation $translation */ |
| 295 |
|
foreach ($product->translations as $key => $translation) { |
| 296 |
|
if (!array_key_exists($group->getName(), $translation->variantLabels)) { |
| 297 |
|
continue; |
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
/** @var \Shopware\Models\Shop\Locale $locale */ |
| 301 |
|
$locale = $this->getLocaleRepository()->findOneBy(['locale' => LocaleMapper::getShopwareLocale($key)]); |
| 302 |
|
|
| 303 |
|
/** @var \Shopware\Models\Shop\Shop $shop */ |
| 304 |
|
$shop = $this->getShopRepository()->findOneBy(['locale' => $locale]); |
| 305 |
|
if (!$shop) { |
| 306 |
|
continue; |
| 307 |
|
} |
| 308 |
|
|
| 309 |
|
foreach ($translation->variantLabels as $groupKey => $groupTranslation) { |
| 310 |
|
if ($groupKey === $group->getName()) { |
| 311 |
|
$this->translationGateway->addGroupTranslation($groupTranslation, $group->getId(), $shop->getId()); |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
} |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
private function addOptionTranslation(Option $option, Product $product) |
| 318 |
|
{ |
|
@@ 317-340 (lines=24) @@
|
| 314 |
|
} |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
private function addOptionTranslation(Option $option, Product $product) |
| 318 |
|
{ |
| 319 |
|
/** @var \Shopware\Connect\Struct\Translation $translation */ |
| 320 |
|
foreach ($product->translations as $key => $translation) { |
| 321 |
|
if (!array_key_exists($option->getName(), $translation->variantValues)) { |
| 322 |
|
continue; |
| 323 |
|
} |
| 324 |
|
|
| 325 |
|
/** @var \Shopware\Models\Shop\Locale $locale */ |
| 326 |
|
$locale = $this->getLocaleRepository()->findOneBy(['locale' => LocaleMapper::getShopwareLocale($key)]); |
| 327 |
|
|
| 328 |
|
/** @var \Shopware\Models\Shop\Shop $shop */ |
| 329 |
|
$shop = $this->getShopRepository()->findOneBy(['locale' => $locale]); |
| 330 |
|
if (!$shop) { |
| 331 |
|
continue; |
| 332 |
|
} |
| 333 |
|
|
| 334 |
|
foreach ($translation->variantValues as $optionKey => $optionTranslation) { |
| 335 |
|
if ($optionKey === $option->getName()) { |
| 336 |
|
$this->translationGateway->addOptionTranslation($optionTranslation, $option->getId(), $shop->getId()); |
| 337 |
|
} |
| 338 |
|
} |
| 339 |
|
} |
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
private function getShopRepository() |
| 343 |
|
{ |