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']); + } +}