mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 06:06:06 +03:00
parent
ef6d09c03a
commit
7d3390bc02
@ -334,13 +334,13 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
: null;
|
||||
|
||||
if (!empty($url) && !empty($key)) {
|
||||
$sites = $this->model_extension_retailcrm_references->getApiSites();
|
||||
$site = $this->model_extension_retailcrm_references->getApiSite();
|
||||
$_data['delivery'] = $this->getAvailableTypes(
|
||||
$sites,
|
||||
$site,
|
||||
$this->model_extension_retailcrm_references->getDeliveryTypes()
|
||||
);
|
||||
$_data['payments'] = $this->getAvailableTypes(
|
||||
$sites,
|
||||
$site,
|
||||
$this->model_extension_retailcrm_references->getPaymentTypes()
|
||||
);
|
||||
$_data['statuses'] = $this->model_extension_retailcrm_references
|
||||
@ -947,26 +947,25 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
return $lastSinceId;
|
||||
}
|
||||
|
||||
private function getAvailableTypes($availableSites, $types)
|
||||
private function getAvailableTypes($availableSite, $types)
|
||||
{
|
||||
if (!empty($availableSites)) {
|
||||
$availableSite = end($availableSites)['code'];
|
||||
} else {
|
||||
return $types;
|
||||
$result['opencart'] = $types['opencart'];
|
||||
$result['retailcrm'] = [];
|
||||
|
||||
if (empty($availableSite)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result['opencart'] = $types['opencart'];
|
||||
|
||||
foreach ($types['retailcrm'] as $codeKey => $type) {
|
||||
if (
|
||||
$type['active'] === true &&
|
||||
(
|
||||
empty($type['sites']) ||
|
||||
in_array($availableSite, $type['sites'], true)
|
||||
)
|
||||
) {
|
||||
$result['retailcrm'][$codeKey] = $type;
|
||||
if ($type['active'] !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($type['sites']) && !in_array($availableSite['code'], $type['sites'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result['retailcrm'][$codeKey] = $type;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -161,15 +161,15 @@ class ModelExtensionRetailcrmReferences extends Model
|
||||
/**
|
||||
* Get RetailCRM available sites list
|
||||
*/
|
||||
public function getApiSites()
|
||||
public function getApiSite()
|
||||
{
|
||||
$response = $this->retailcrmApiClient->sitesList();
|
||||
|
||||
if (!$response) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return (!$response->isSuccessful()) ? array() : $response->sites;
|
||||
return (!$response->isSuccessful()) ? [] : end($response->sites);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class ControllerRetailcrmAdminTest extends TestCase
|
||||
public function testGetAvailableTypes()
|
||||
{
|
||||
$data = $this->getDataForTestAvailableTypes();
|
||||
$sites = $data['sites'];
|
||||
$sites = end($data['site']);
|
||||
$types = $data['types'];
|
||||
|
||||
$retailCrm = new ControllerExtensionModuleRetailcrm(self::$registry);
|
||||
@ -65,7 +65,7 @@ class ControllerRetailcrmAdminTest extends TestCase
|
||||
private function getDataForTestAvailableTypes(): array
|
||||
{
|
||||
return [
|
||||
'sites' => [
|
||||
'site' => [
|
||||
'opencart' => [
|
||||
'code' => 'opencart',
|
||||
'name' => 'OpenCart'
|
||||
|
Loading…
Reference in New Issue
Block a user