b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / Amasty / OrderImport / Model / Profile /
Filename/home/dev2.destoffenstraat.com/app/code/Amasty/OrderImport/Model/Profile/ProfileRunner.php
Size3.03 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified14-Jun-2025 23:40
Last accessed22-Aug-2025 14:04
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

declare(strict_types = 1);

/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Import Orders for Magento 2
*/

namespace Amasty\OrderImport\Model\Profile;

use Amasty\ImportCore\Api\Config\ProfileConfigInterface;
use Amasty\ImportCore\Processing\JobManager;
use Amasty\ImportExportCore\Api\Profile\ProfileRunnerInterface;
use Amasty\ImportExportCore\Utils\Serializer;
use Amasty\OrderImport\Api\ProfileRepositoryInterface;
use Amasty\OrderImport\Model\ConfigProvider;
use Amasty\OrderImport\Model\ModuleType;

class ProfileRunner implements ProfileRunnerInterface
{
/**
* @var ProfileRepositoryInterface
*/
private $profileRepository;

/**
* @var ConfigProvider
*/
private $configProvider;

/**
* @var JobManager
*/
private $jobManager;

/**
* @var Serializer
*/
private $serializer;

public function __construct(
ProfileRepositoryInterface $profileRepository,
ConfigProvider $configProvider,
JobManager $jobManager,
Serializer $serializer
) {
$this->profileRepository = $profileRepository;
$this->configProvider = $configProvider;
$this->jobManager = $jobManager;
$this->serializer = $serializer;
}

public function run(int $profileId, \Closure $profileConfigModifier = null): string
{
$processIdentity = $this->getProcessIdentity();
$this->jobManager->requestJob(
$this->prepareProfileConfig($profileId, $profileConfigModifier),
$processIdentity
);

return $processIdentity;
}

public function manualRun(int $profileId, \Closure $profileConfigModifier = null): string
{
$processIdentity = $this->getProcessIdentity();
$profileConfig = $this->prepareProfileConfig($profileId, $profileConfigModifier);
$profileConfig->getExtensionAttributes()->setManualRun(true);
$this->jobManager->requestJob($profileConfig, $processIdentity);

return $processIdentity;
}

public function prepareProfileConfig(int $profileId, \Closure $profileConfigModifier = null): ProfileConfigInterface
{
$profile = $this->profileRepository->getById($profileId);
$profileConfig = $profile->getConfig();
$profileConfig->setModuleType(ModuleType::TYPE);
$profileConfig->getExtensionAttributes()->setName($profile->getName());
$profileConfig->getExtensionAttributes()->setExternalId($profile->getId());
$profileConfig->setIsUseMultiProcess($this->configProvider->useMultiProcess());
$profileConfig->setMaxJobs($this->configProvider->getMaxProcessCount());

if ($profileConfig->getBatchSize() === null) {
$profileConfig->setBatchSize($this->configProvider->getBatchSize());
}

if ($profileConfigModifier) {
$profileConfigModifier($profileConfig);
}

return $profileConfig;
}

protected function getProcessIdentity(): string
{
return uniqid('order_import_');
}
}