Created
November 23, 2015 15:01
-
-
Save maximzasorin/9a00681cfe36c7fc8f1c 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: | |
* | |
// KAD: Скрываем модификации, которых нет в наличии на текущем складе | |
Core_Event::attach('shop_item.onBeforeShowXmlModifications', array('Shop_Item_Observers_Hidenotavailablemods', 'onBeforeShowXmlModifications')); | |
* | |
*/ | |
defined('HOSTCMS') || exit('HostCMS: access denied.'); | |
class Shop_Item_Observers_Hidenotavailablemods | |
{ | |
static public function onBeforeShowXmlModifications($object, $args) | |
{ | |
if ( | |
( | |
defined('HIDE_NOT_AVAILABLE_MODS_SHOP_ID') | |
&& | |
HIDE_NOT_AVAILABLE_MODS_SHOP_ID == $object->shop_id | |
) | |
) | |
{ | |
$oShop = Core_Entity::factory('Shop', HIDE_NOT_AVAILABLE_MODS_SHOP_ID); | |
$oCurrent_Warehouse = $oShop->Shop_Warehouses->getDefault(); | |
$args[0]->queryBuilder() | |
->select('shop_items.*') | |
->leftJoin('shop_warehouse_items', 'shop_warehouse_items.shop_item_id', '=', 'shop_items.id', array( | |
array( | |
'AND' => array('shop_warehouse_items.shop_warehouse_id', '=', $oCurrent_Warehouse->id) | |
) | |
) | |
) | |
->where('shop_warehouse_items.count', '>', 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment