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 / a / home / dev2.destoffenstraat.com / app / code / Amasty / OrderImport / Import / Form /
Filename/home/a/home/dev2.destoffenstraat.com/app/code/Amasty/OrderImport/Import/Form/ImportSettings.php
Size5.19 kb
Permissionrw-r--r--
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified14-Jun-2025 23:40
Last accessed23-Aug-2025 01:52
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\Import\Form;

use Amasty\ImportCore\Api\Config\EntityConfigInterface;
use Amasty\ImportCore\Api\Config\ProfileConfigInterface;
use Amasty\ImportCore\Api\FormInterface;
use Amasty\ImportCore\Import\Form\Fields\IdentifiersCollector;
use Amasty\ImportCore\Import\OptionSource\ValidationStrategy;
use Amasty\OrderImport\Model\OptionSource\CustomerMode;
use Amasty\OrderImport\Model\OptionSource\OrderIdentifier;
use Amasty\OrderImport\Ui\DataProvider\Profile\CompositeFormType;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\UrlInterface;

class ImportSettings extends \Amasty\ImportCore\Import\Form\General
{
/**
* @var CustomerMode
*/
private $customerMode;

/**
* @var RequestInterface
*/
private $request;

/**
* @var IdentifiersCollector
*/
private $identifiersCollector;

public function __construct(
ValidationStrategy $validationStrategy,
UrlInterface $url,
CustomerMode $customerMode,
RequestInterface $request,
IdentifiersCollector $identifiersCollector
) {
parent::__construct($validationStrategy, $url);
$this->customerMode = $customerMode;
$this->request = $request;
$this->identifiersCollector = $identifiersCollector;
}

public function getMeta(EntityConfigInterface $entityConfig, array $arguments = []): array
{
$meta = parent::getMeta($entityConfig, $arguments);

$meta['import_behavior']['children']['form_type']['arguments']['data']['config']['value']
= CompositeFormType::TYPE;

$meta['import_behavior']['children']['customer_mode']['arguments']['data']['config'] = [
'label' => __('Customer Mode'),
'visible' => true,
'dataScope' => 'customer_mode',
'dataType' => 'select',
'formElement' => 'select',
'componentType' => 'select',
'additionalClasses' => 'amimportcore-field',
'options' => $this->customerMode->toOptionArray()
];

if (!$this->request->getParam('id')) {
$meta['import_behavior']['children']['autofill']['arguments']['data']['config'] = [
'label' => __('Enable Autofill for Typical Use Cases'),
'dataType' => 'boolean',
'prefer' => 'toggle',
'visible' => true,
'dataScope' => 'autofill',
'formElement' => 'checkbox',
'componentType' => 'field',
'additionalClasses' => 'amimportcore-field',
'sortOrder' => 11,
'valueMap' => ['true' => 1, 'false' => 0],
'default' => 0,
'tooltipTpl' => 'Amasty_ImportCore/form/element/tooltip',
'tooltip' => [
'description' => __(
'If enabled, Fields Configuration will be automatically filled in'
. ' with the settings to perform the typical use cases for importing'
. ' orders from third-party systems.'
)
]
];
}

$meta['import_behavior']['children']['entity_identifier']['arguments']['data']['config'] = [
'label' => 'Order Identifier',
'component' => 'Amasty_ImportPro/js/form/element/entity-identifier',
'visible' => true,
'dataScope' => 'entity_identifier',
'dataType' => 'select',
'formElement' => 'select',
'componentType' => 'select',
'additionalClasses' => 'amimportcore-field',
'sortOrder' => 15,
'options' => $this->identifiersCollector->collect($entityConfig)
];

return $meta;
}

public function getData(ProfileConfigInterface $profileConfig): array
{
$importBehavior = parent::getData($profileConfig);

$data = ['import_behavior' => $importBehavior];
if ($customerMode = $profileConfig->getExtensionAttributes()->getCustomerMode()) {
$data['import_behavior']['customer_mode'] = $customerMode;
}

if ($entityIdentifier = $profileConfig->getEntityIdentifier()) {
$data['import_behavior']['entity_identifier'] = $entityIdentifier;
}

return $data;
}

public function prepareConfig(ProfileConfigInterface $profileConfig, RequestInterface $request): FormInterface
{
$params = $request->getParams();
$importBehavior = $params['import_behavior'] ?? [];
unset($params['import_behavior']);
$params = array_merge_recursive($params, $importBehavior);
$request->setParams($params);

parent::prepareConfig($profileConfig, $request);

if ($customerMode = $request->getParam('customer_mode')) {
$profileConfig->getExtensionAttributes()->setCustomerMode($customerMode);
}

if ($entityIdentifier = $request->getParam('entity_identifier')) {
$profileConfig->setEntityIdentifier($entityIdentifier);
}

return $this;
}
}