From ec022db8b543039b0babf5f790da589a04d26958 Mon Sep 17 00:00:00 2001 From: dkorol Date: Thu, 7 Apr 2016 13:03:09 +0300 Subject: [PATCH] added comparing version, because model sale/customer from 2.1 version comes to customer/customer --- admin/model/retailcrm/history.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/admin/model/retailcrm/history.php b/admin/model/retailcrm/history.php index 2552c72..3765da0 100644 --- a/admin/model/retailcrm/history.php +++ b/admin/model/retailcrm/history.php @@ -9,7 +9,11 @@ class ModelRetailcrmHistory extends Model $this->load->model('setting/setting'); $this->load->model('setting/store'); $this->load->model('sale/order'); - $this->load->model('sale/customer'); + if (version_compare(VERSION, '2.1.0.0', '>=')) { + $this->load->model('customer/customer'); + } else { + $this->load->model('sale/customer'); + } $this->load->model('retailcrm/references'); $this->load->model('catalog/product'); $this->load->model('localisation/zone'); @@ -281,13 +285,25 @@ class ModelRetailcrmHistory extends Model ), ); - $this->model_sale_customer->addCustomer($cData); + if (version_compare(VERSION, '2.1.0.0', '>=')) { + $this->model_customer_customer->addCustomer($cData); + } else { + $this->model_sale_customer->addCustomer($cData); + } if (!empty($order['email'])) { - $tryToFind = $this->model_sale_customer->getCustomerByEmail($order['email']); + if (version_compare(VERSION, '2.1.0.0', '>=')) { + $tryToFind = $this->model_customer_customer->getCustomerByEmail($order['email']); + } else { + $tryToFind = $this->model_sale_customer->getCustomerByEmail($order['email']); + } $customer_id = $tryToFind['customer_id']; } else { - $last = $this->model_sale_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1)); + if (version_compare(VERSION, '2.1.0.0', '>=')) { + $last = $this->model_customer_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1)); + } else { + $last = $this->model_sale_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1)); + } $customer_id = $last[0]['customer_id']; }