From 8b8350a290b3ceb9b178185620b3766d4c1aac38 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 1 Aug 2018 09:31:40 +0300 Subject: [PATCH] Bug fixes --- .../controller/extension/module/retailcrm.php | 2 +- .../admin/model/extension/retailcrm/order.php | 32 +++++++++++++------ .../model/extension/retailcrm/order.php | 20 +++++++----- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index e4d19fd..8a11213 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -519,7 +519,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->load->model('extension/retailcrm/order'); $this->model_extension_retailcrm_order->uploadOrder($data, $this->retailcrm->getApiClient()); - $response = $this->model_extension_retailcrm_order->getLastResponse(); + $response = ModelExtensionRetailcrmOrder::getLastResponse(); } if (!$response->isSuccessful()) { diff --git a/src/upload/admin/model/extension/retailcrm/order.php b/src/upload/admin/model/extension/retailcrm/order.php index feed665..4f147aa 100644 --- a/src/upload/admin/model/extension/retailcrm/order.php +++ b/src/upload/admin/model/extension/retailcrm/order.php @@ -5,6 +5,8 @@ class ModelExtensionRetailcrmOrder extends Model { protected $moduleTitle; protected $retailcrmApiClient; + protected static $lastRepsonse = null; + public function __construct($registry) { parent::__construct($registry); @@ -81,7 +83,7 @@ class ModelExtensionRetailcrmOrder extends Model { unset($customers); - $retailcrmApiClient->ordersCreate($order); + self::$lastRepsonse = $retailcrmApiClient->ordersCreate($order); return $order; } @@ -116,16 +118,20 @@ class ModelExtensionRetailcrmOrder extends Model { } if (!isset($delivery_code) && isset($shippingModule)) { - $deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']); - $shipping_code = ''; + if (isset($this->settings[$this->moduleTitle . '_delivery']) + && $this->settings[$this->moduleTitle . '_delivery'] + ) { + $deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']); + $shipping_code = ''; - array_walk($deliveries, function($item, $key) use ($shippingModule, &$shipping_code) { - if (strripos($item, $shippingModule) !== false) { - $shipping_code = $item; - } - }); + array_walk($deliveries, function($item, $key) use ($shippingModule, &$shipping_code) { + if (strripos($item, $shippingModule) !== false) { + $shipping_code = $item; + } + }); - $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code]; + $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code]; + } } if (!empty($order_data['payment_iso_code_2'])) { @@ -281,4 +287,12 @@ class ModelExtensionRetailcrmOrder extends Model { return $order; } + + /** + * @return mixed + */ + public static function getLastResponse() + { + return self::$lastRepsonse; + } } diff --git a/src/upload/catalog/model/extension/retailcrm/order.php b/src/upload/catalog/model/extension/retailcrm/order.php index c93a50b..bbffb03 100644 --- a/src/upload/catalog/model/extension/retailcrm/order.php +++ b/src/upload/catalog/model/extension/retailcrm/order.php @@ -82,16 +82,20 @@ class ModelExtensionRetailcrmOrder extends Model { } if (!isset($delivery_code) && isset($shippingModule)) { - $deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']); - $shipping_code = ''; + if (isset($this->settings[$this->moduleTitle . '_delivery']) + && $this->settings[$this->moduleTitle . '_delivery'] + ) { + $deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']); + $shipping_code = ''; - array_walk($deliveries, function($item, $key) use ($shippingModule, &$shipping_code) { - if (strripos($item, $shippingModule) !== false) { - $shipping_code = $item; - } - }); + array_walk($deliveries, function ($item, $key) use ($shippingModule, &$shipping_code) { + if (strripos($item, $shippingModule) !== false) { + $shipping_code = $item; + } + }); - $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code]; + $delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code]; + } } if (!empty($order_data['payment_iso_code_2'])) {