| @@ 341-369 (lines=29) @@ | ||
| 338 | * |
|
| 339 | * @param array $data |
|
| 340 | */ |
|
| 341 | public function setImportConfigs($data) |
|
| 342 | { |
|
| 343 | foreach ($data as $config) { |
|
| 344 | unset($config['id']); |
|
| 345 | foreach ($config as $key => $configValue) { |
|
| 346 | /** @var \Shopware\CustomModels\Connect\Config $model */ |
|
| 347 | $model = $this->getConfigRepository()->findOneBy([ |
|
| 348 | 'name' => $key, |
|
| 349 | 'shopId' => null, |
|
| 350 | 'groupName' => 'import' |
|
| 351 | ]); |
|
| 352 | if (is_null($model)) { |
|
| 353 | $model = new ConfigModel(); |
|
| 354 | $model->setName($key); |
|
| 355 | $model->setGroupName('import'); |
|
| 356 | $model->setShopId(null); |
|
| 357 | } |
|
| 358 | ||
| 359 | if (is_array($configValue)) { |
|
| 360 | $model->setValue(json_encode($configValue)); |
|
| 361 | } else { |
|
| 362 | $model->setValue($configValue); |
|
| 363 | } |
|
| 364 | $this->manager->persist($model); |
|
| 365 | } |
|
| 366 | } |
|
| 367 | ||
| 368 | $this->manager->flush(); |
|
| 369 | } |
|
| 370 | ||
| 371 | /** |
|
| 372 | * Helper function which returns export configuration. |
|
| @@ 393-422 (lines=30) @@ | ||
| 390 | return $result; |
|
| 391 | } |
|
| 392 | ||
| 393 | public function setExportConfigs($data) |
|
| 394 | { |
|
| 395 | foreach ($data as $config) { |
|
| 396 | unset($config['id']); |
|
| 397 | foreach ($config as $key => $configValue) { |
|
| 398 | /** @var \Shopware\CustomModels\Connect\Config $model */ |
|
| 399 | $model = $this->getConfigRepository()->findOneBy([ |
|
| 400 | 'name' => $key, |
|
| 401 | 'shopId' => null, |
|
| 402 | 'groupName' => 'export' |
|
| 403 | ]); |
|
| 404 | if (is_null($model)) { |
|
| 405 | $model = new ConfigModel(); |
|
| 406 | $model->setName($key); |
|
| 407 | $model->setGroupName('export'); |
|
| 408 | $model->setShopId(null); |
|
| 409 | } |
|
| 410 | ||
| 411 | if (is_array($configValue)) { |
|
| 412 | $model->setValue(json_encode($configValue)); |
|
| 413 | } else { |
|
| 414 | $model->setValue($configValue); |
|
| 415 | } |
|
| 416 | ||
| 417 | $this->manager->persist($model); |
|
| 418 | } |
|
| 419 | } |
|
| 420 | ||
| 421 | $this->manager->flush(); |
|
| 422 | } |
|
| 423 | ||
| 424 | /** |
|
| 425 | * Stores units mapping |
|