mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 14:16:07 +03:00
ref #90088 Types of deliveries and payments are displayed only active status and available stores
This commit is contained in:
commit
6a7f395116
@ -2,7 +2,7 @@ FROM php:7.1-apache
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -y netcat zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev \
|
||||
RUN apt-get install -y netcat zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip \
|
||||
&& docker-php-ext-configure intl \
|
||||
&& docker-php-ext-install intl \
|
||||
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
|
||||
|
@ -1,3 +1,6 @@
|
||||
## v4.1.10
|
||||
* Types of deliveries and payments are displayed only active status and available stores
|
||||
|
||||
## v4.1.9
|
||||
* Optimization of the history processing algorithm
|
||||
|
||||
|
@ -334,13 +334,17 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
: null;
|
||||
|
||||
if (!empty($url) && !empty($key)) {
|
||||
|
||||
$_data['delivery'] = $this->model_extension_retailcrm_references
|
||||
->getDeliveryTypes();
|
||||
$site = $this->model_extension_retailcrm_references->getApiSite();
|
||||
$_data['delivery'] = $this->getAvailableTypes(
|
||||
$site,
|
||||
$this->model_extension_retailcrm_references->getDeliveryTypes()
|
||||
);
|
||||
$_data['payments'] = $this->getAvailableTypes(
|
||||
$site,
|
||||
$this->model_extension_retailcrm_references->getPaymentTypes()
|
||||
);
|
||||
$_data['statuses'] = $this->model_extension_retailcrm_references
|
||||
->getOrderStatuses();
|
||||
$_data['payments'] = $this->model_extension_retailcrm_references
|
||||
->getPaymentTypes();
|
||||
$_data['customFields'] = $this->model_extension_retailcrm_references
|
||||
->getCustomFields();
|
||||
|
||||
@ -942,4 +946,28 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
|
||||
return $lastSinceId;
|
||||
}
|
||||
|
||||
private function getAvailableTypes($availableSite, $types)
|
||||
{
|
||||
$result['opencart'] = $types['opencart'];
|
||||
$result['retailcrm'] = [];
|
||||
|
||||
if (empty($availableSite)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($types['retailcrm'] as $codeKey => $type) {
|
||||
if ($type['active'] !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($type['sites']) && !in_array($availableSite['code'], $type['sites'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result['retailcrm'][$codeKey] = $type;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,22 @@ class ModelExtensionRetailcrmReferences extends Model
|
||||
return (!$response->isSuccessful()) ? array() : $response->deliveryTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RetailCRM available sites list
|
||||
*/
|
||||
public function getApiSite()
|
||||
{
|
||||
$response = $this->retailcrmApiClient->sitesList();
|
||||
|
||||
if (!$response || !$response->isSuccessful()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sites = $response->sites;
|
||||
|
||||
return end($sites);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RetailCRM order statuses
|
||||
*
|
||||
|
@ -41,4 +41,63 @@ class ControllerRetailcrmAdminTest extends TestCase
|
||||
$response = $this->dispatchAction('extension/module/retailcrm/uninstall_collector');
|
||||
$this->assertRegExp('/Connection settings/', $response->getOutput());
|
||||
}
|
||||
|
||||
public function testGetAvailableTypes()
|
||||
{
|
||||
$data = $this->getDataForTestAvailableTypes();
|
||||
$sites = end($data['site']);
|
||||
$types = $data['types'];
|
||||
|
||||
$retailCrm = new ControllerExtensionModuleRetailcrm(self::$registry);
|
||||
$class = new ReflectionClass($retailCrm);
|
||||
$method = $class->getMethod('getAvailableTypes');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs($retailCrm, [$sites, $types]);
|
||||
|
||||
$this->assertNotEmpty($result['opencart']);
|
||||
$this->assertNotEmpty($result['retailcrm']);
|
||||
$this->assertCount(2, $result['retailcrm']);
|
||||
$this->assertNotEmpty($result['retailcrm']['test1']['code']);
|
||||
$this->assertNotEmpty($result['retailcrm']['test4']['code']);
|
||||
}
|
||||
|
||||
private function getDataForTestAvailableTypes(): array
|
||||
{
|
||||
return [
|
||||
'site' => [
|
||||
'opencart' => [
|
||||
'code' => 'opencart',
|
||||
'name' => 'OpenCart'
|
||||
]
|
||||
],
|
||||
'types' => [
|
||||
'opencart' => [
|
||||
'test'
|
||||
],
|
||||
'retailcrm' => [
|
||||
'test1' => [
|
||||
'active' => true,
|
||||
'sites' => [],
|
||||
'code' => 'test1'
|
||||
],
|
||||
'test2' => [
|
||||
'active' => false,
|
||||
'sites' => [],
|
||||
'code' => 'test2'
|
||||
],
|
||||
'test3' => [
|
||||
'active' => true,
|
||||
'sites' => ['otherSite'],
|
||||
'code' => 'test3'
|
||||
],
|
||||
'test4' => [
|
||||
'active' => true,
|
||||
'sites' => ['cms1', 'cms2', 'opencart'],
|
||||
'code' => 'test4'
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user