Добавил полчение события из БД для OC 3.0

This commit is contained in:
Akolzin Dmitry 2018-12-05 17:10:00 +03:00
parent 3e55de0e3a
commit cfcac1e013
4 changed files with 46 additions and 5 deletions

View File

@ -1,3 +1,6 @@
## v.3.1.6
* Исправлено получение событий из БД для OC 3.0
## v.3.1.5
* Исправление ошибок

View File

@ -860,11 +860,16 @@ class ControllerExtensionModuleRetailcrm extends Controller
*/
private function checkEvents()
{
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;

View File

@ -0,0 +1,8 @@
<?php
class ModelExtensionRetailcrmEvent extends Model{
public function getEventByCode($code) {
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
return $query->row;
}
}

View File

@ -0,0 +1,25 @@
<?php
class ModelRetailcrmEventAdminTest extends OpenCartTest
{
const CODE = 'test';
protected function setUp()
{
parent::setUp();
$eventModel = $this->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']);
}
}