Last active
November 20, 2015 17:32
-
-
Save maximzasorin/558b00284a7fd69ae8e0 to your computer and use it in GitHub Desktop.
Наблюдатель для запрета индексации модификаций товаров, которых нет в наличии (HostCMS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* В bootstrap.php: | |
* | |
// Запрет индексации модификаций и товаров, которых нет в наличии | |
Core_Event::attach('shop_item.onAfterSave', array('Shop_Item_Observers_Setindexing', 'onAfterSave')); | |
* | |
*/ | |
defined('HOSTCMS') || exit('HostCMS: access denied.'); | |
class Shop_Item_Observers_Setindexing | |
{ | |
static public function onAfterSave($object, $args) | |
{ | |
// Запрещаем индексацию модификаций и товаров, которых нет в наличии | |
if ( | |
($object->getRest() == 0 || $object->modification_id != 0) | |
&& | |
$object->indexing == 1 | |
) | |
{ | |
$object->indexing = 0; | |
$object->save(); | |
} | |
// Разрешаем индексацию немодификаций, которые есть в наличии | |
else if ( | |
($object->getRest() > 0 && $object->modification_id == 0) | |
&& | |
$object->indexing == 0 | |
) | |
{ | |
$object->indexing = 1; | |
$object->save(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment