This commit is contained in:
Akolzin Dmitry 2018-06-14 11:26:15 +03:00
parent 26a6a0731c
commit 2c4306dad1
4 changed files with 16 additions and 16 deletions

View File

@ -147,20 +147,16 @@ class ControllerApiRetailcrm extends Controller
if ( version_compare(VERSION, '3.0', '<')) {
$api = $this->model_account_api->getApiByKey($this->request->get['key']);
} else {
$api = $this->model_account_api->login($this->request->get['username'], $this->request->get['key']);
if (empty($api)) {
$this->load->model('extension/retailcrm/api');
$api = $this->model_extension_retailcrm_api->login($this->request->get['username'], $this->request->get['key']);
}
$this->load->model('extension/retailcrm/api');
$api = $this->model_extension_retailcrm_api->login($this->request->get['username'], $this->request->get['key']);
}
if (!empty($api)) {
return $api;
}
return array('error' => 'Invalid api key');
}
return array('error' => 'Invalid api key');
}
private function loadModels()

View File

@ -13,8 +13,10 @@ class ControllerExtensionModuleRetailcrm extends Controller {
private $retailcrmApiClient;
public function __construct()
public function __construct($registry)
{
parent::__construct($registry);
$this->load->library('retailcrm/retailcrm');
$this->retailcrmApiClient = $this->retailcrm->getApiClient();
}
@ -29,9 +31,13 @@ class ControllerExtensionModuleRetailcrm extends Controller {
* @return void
*/
public function order_create($trigger, $data, $order_id = null) {
$this->load->model('checkout/order');
$this->load->model('account/order');
$this->load->library('retailcrm/retailcrm');
$data = $this->model_checkout_order->getOrder($order_id);;
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
$data['totals'] = $this->model_account_order->getOrderTotals($order_id);
$moduleTitle = $this->retailcrm->getModuleTitle();
foreach ($data['products'] as $key => $product) {

View File

@ -295,9 +295,11 @@ class ModelExtensionRetailcrmOrder extends Model {
100
);
if ($response->isSuccessful()) {
if ($response['customers']) {
$customer = end($response['customers']);
if ($response->isSuccessful() && isset($response['customers'])) {
$customers = $response['customers'];
if ($customers) {
$customer = end($customers);
}
}

View File

@ -32,10 +32,6 @@ class Retailcrm {
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
if (!$setting) {
return false;
}
if ($apiUrl === null && $apiKey === null) {
$apiUrl = isset($setting[$this->getModuleTitle() . '_url'])
? $setting[$this->getModuleTitle() . '_url'] : '';