mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 13:16:07 +03:00
Bug fix
This commit is contained in:
parent
26a6a0731c
commit
2c4306dad1
@ -147,20 +147,16 @@ class ControllerApiRetailcrm extends Controller
|
|||||||
if ( version_compare(VERSION, '3.0', '<')) {
|
if ( version_compare(VERSION, '3.0', '<')) {
|
||||||
$api = $this->model_account_api->getApiByKey($this->request->get['key']);
|
$api = $this->model_account_api->getApiByKey($this->request->get['key']);
|
||||||
} else {
|
} else {
|
||||||
$api = $this->model_account_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)) {
|
|
||||||
$this->load->model('extension/retailcrm/api');
|
|
||||||
$api = $this->model_extension_retailcrm_api->login($this->request->get['username'], $this->request->get['key']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($api)) {
|
if (!empty($api)) {
|
||||||
return $api;
|
return $api;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('error' => 'Invalid api key');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array('error' => 'Invalid api key');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadModels()
|
private function loadModels()
|
||||||
|
@ -13,8 +13,10 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
|||||||
|
|
||||||
private $retailcrmApiClient;
|
private $retailcrmApiClient;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct($registry)
|
||||||
{
|
{
|
||||||
|
parent::__construct($registry);
|
||||||
|
|
||||||
$this->load->library('retailcrm/retailcrm');
|
$this->load->library('retailcrm/retailcrm');
|
||||||
$this->retailcrmApiClient = $this->retailcrm->getApiClient();
|
$this->retailcrmApiClient = $this->retailcrm->getApiClient();
|
||||||
}
|
}
|
||||||
@ -29,9 +31,13 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function order_create($trigger, $data, $order_id = null) {
|
public function order_create($trigger, $data, $order_id = null) {
|
||||||
|
$this->load->model('checkout/order');
|
||||||
$this->load->model('account/order');
|
$this->load->model('account/order');
|
||||||
$this->load->library('retailcrm/retailcrm');
|
$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();
|
$moduleTitle = $this->retailcrm->getModuleTitle();
|
||||||
|
|
||||||
foreach ($data['products'] as $key => $product) {
|
foreach ($data['products'] as $key => $product) {
|
||||||
|
@ -295,9 +295,11 @@ class ModelExtensionRetailcrmOrder extends Model {
|
|||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($response->isSuccessful()) {
|
if ($response->isSuccessful() && isset($response['customers'])) {
|
||||||
if ($response['customers']) {
|
$customers = $response['customers'];
|
||||||
$customer = end($response['customers']);
|
|
||||||
|
if ($customers) {
|
||||||
|
$customer = end($customers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,6 @@ class Retailcrm {
|
|||||||
|
|
||||||
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
$setting = $this->model_setting_setting->getSetting($this->getModuleTitle());
|
||||||
|
|
||||||
if (!$setting) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($apiUrl === null && $apiKey === null) {
|
if ($apiUrl === null && $apiKey === null) {
|
||||||
$apiUrl = isset($setting[$this->getModuleTitle() . '_url'])
|
$apiUrl = isset($setting[$this->getModuleTitle() . '_url'])
|
||||||
? $setting[$this->getModuleTitle() . '_url'] : '';
|
? $setting[$this->getModuleTitle() . '_url'] : '';
|
||||||
|
Loading…
Reference in New Issue
Block a user