From cfcac1e013b1384ea3ee65ce326cc49902b2af25 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 5 Dec 2018 17:10:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=20=D0=B8=D0=B7=20=D0=91=D0=94=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20OC=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ .../controller/extension/module/retailcrm.php | 15 +++++++---- .../admin/model/extension/retailcrm/event.php | 8 ++++++ tests/admin/ModelRetailcrmEventAdminTest.php | 25 +++++++++++++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/upload/admin/model/extension/retailcrm/event.php create mode 100644 tests/admin/ModelRetailcrmEventAdminTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index bd9c77a..b11d392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v.3.1.6 +* Исправлено получение событий из БД для OC 3.0 + ## v.3.1.5 * Исправление ошибок diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index c45b048..0bf0f00 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -860,11 +860,16 @@ class ControllerExtensionModuleRetailcrm extends Controller */ private function checkEvents() { - $events = $this->{'model_' . $this->modelEvent}->getEvent( - $this->moduleTitle, - 'catalog/model/checkout/order/addOrder/after', - 'extension/module/retailcrm/order_create' - ); + if (version_compare(VERSION, '3.0', '<')) { + $events = $this->{'model_' . $this->modelEvent}->getEvent( + $this->moduleTitle, + 'catalog/model/checkout/order/addOrder/after', + 'extension/module/retailcrm/order_create' + ); + } else { + $this->load->model('extension/retailcrm/event'); + $events = $this->model_extension_retailcrm_event->getEventByCode($this->moduleTitle); + } if (!empty($events)) { return true; diff --git a/src/upload/admin/model/extension/retailcrm/event.php b/src/upload/admin/model/extension/retailcrm/event.php new file mode 100644 index 0000000..5a86d6c --- /dev/null +++ b/src/upload/admin/model/extension/retailcrm/event.php @@ -0,0 +1,8 @@ +db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1"); + return $query->row; + } +} diff --git a/tests/admin/ModelRetailcrmEventAdminTest.php b/tests/admin/ModelRetailcrmEventAdminTest.php new file mode 100644 index 0000000..ba1f05a --- /dev/null +++ b/tests/admin/ModelRetailcrmEventAdminTest.php @@ -0,0 +1,25 @@ +loadModel('extension/event'); + $eventModel->addEvent(self::CODE, 'test', 'test'); + } + + public function testGetEvent() + { + $eventModel = $this->loadModel('extension/retailcrm/event'); + $event = $eventModel->getEventByCode(self::CODE); + + $this->assertNotEmpty($event); + $this->assertEquals(self::CODE, $event['code']); + $this->assertEquals('test', $event['trigger']); + $this->assertEquals('test', $event['action']); + } +}