Merge pull request #122 from iyzoer/master

v3.1.6
This commit is contained in:
Alex Lushpai 2018-12-05 17:21:45 +03:00 committed by GitHub
commit d54e5e8c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 6 deletions

View File

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

View File

@ -1 +1 @@
3.1.5 3.1.6

View File

@ -860,11 +860,16 @@ class ControllerExtensionModuleRetailcrm extends Controller
*/ */
private function checkEvents() private function checkEvents()
{ {
$events = $this->{'model_' . $this->modelEvent}->getEvent( if (version_compare(VERSION, '3.0', '<')) {
$this->moduleTitle, $events = $this->{'model_' . $this->modelEvent}->getEvent(
'catalog/model/checkout/order/addOrder/after', $this->moduleTitle,
'extension/module/retailcrm/order_create' '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)) { if (!empty($events)) {
return true; 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']);
}
}