mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 14:46:06 +03:00
Bug fix
This commit is contained in:
parent
26a6a0731c
commit
2c4306dad1
@ -147,21 +147,17 @@ 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']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($api)) {
|
||||
return $api;
|
||||
}
|
||||
}
|
||||
|
||||
return array('error' => 'Invalid api key');
|
||||
}
|
||||
}
|
||||
|
||||
private function loadModels()
|
||||
{
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'] : '';
|
||||
|
Loading…
Reference in New Issue
Block a user