| @@ 341-377 (lines=37) @@ | ||
| 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 | if ($key === 'importImagesOnFirstImport') { |
|
| 367 | if ($configValue == 0) { |
|
| 368 | $this->activateConnectCronJob('ShopwareConnectImportImages', 1); |
|
| 369 | } else { |
|
| 370 | $this->activateConnectCronJob('ShopwareConnectImportImages', 0); |
|
| 371 | } |
|
| 372 | } |
|
| 373 | } |
|
| 374 | } |
|
| 375 | ||
| 376 | $this->manager->flush(); |
|
| 377 | } |
|
| 378 | ||
| 379 | /** |
|
| 380 | * Helper function which returns export configuration. |
|
| @@ 401-438 (lines=38) @@ | ||
| 398 | return $result; |
|
| 399 | } |
|
| 400 | ||
| 401 | public function setExportConfigs($data) |
|
| 402 | { |
|
| 403 | foreach ($data as $config) { |
|
| 404 | unset($config['id']); |
|
| 405 | foreach ($config as $key => $configValue) { |
|
| 406 | /** @var \Shopware\CustomModels\Connect\Config $model */ |
|
| 407 | $model = $this->getConfigRepository()->findOneBy([ |
|
| 408 | 'name' => $key, |
|
| 409 | 'shopId' => null, |
|
| 410 | 'groupName' => 'export' |
|
| 411 | ]); |
|
| 412 | if (is_null($model)) { |
|
| 413 | $model = new ConfigModel(); |
|
| 414 | $model->setName($key); |
|
| 415 | $model->setGroupName('export'); |
|
| 416 | $model->setShopId(null); |
|
| 417 | } |
|
| 418 | ||
| 419 | if (is_array($configValue)) { |
|
| 420 | $model->setValue(json_encode($configValue)); |
|
| 421 | } else { |
|
| 422 | $model->setValue($configValue); |
|
| 423 | } |
|
| 424 | ||
| 425 | $this->manager->persist($model); |
|
| 426 | ||
| 427 | if ($key === 'autoUpdateProducts') { |
|
| 428 | if ($configValue == self::UPDATE_CRON_JOB) { |
|
| 429 | $this->activateConnectCronJob('ShopwareConnectUpdateProducts', 1); |
|
| 430 | } else { |
|
| 431 | $this->activateConnectCronJob('ShopwareConnectUpdateProducts', 0); |
|
| 432 | } |
|
| 433 | } |
|
| 434 | } |
|
| 435 | } |
|
| 436 | ||
| 437 | $this->manager->flush(); |
|
| 438 | } |
|
| 439 | ||
| 440 | /** |
|
| 441 | * Stores units mapping |
|