Обработчик размещаем в коде типовой динамической страницы.
// Если идет показ товара
if ($Shop_Controller_Show->item){
class Shop_Item_Observer_Prices
{
static public function onBeforeGetXml($object, $args)
{
$oPrices = Core::factory('Core_Xml_Entity')
->name('prices');
$oShop = $object->Shop;
$aShop_Currencies = Core_Entity::factory('Shop_Currency')->findAll();
foreach ($aShop_Currencies as $oShop_Currency)
{
$fCurrencyCoefficient = $object->shop_currency_id > 0 && $oShop_Currency->id > 0
? Shop_Controller::instance()->getCurrencyCoefficientInShopCurrency(
$object->Shop_Currency, $oShop_Currency
)
: 0;
// Prices
$oShop_Item_Controller = new Shop_Item_Controller();
if (Core::moduleIsActive('siteuser'))
{
$oSiteuser = Core_Entity::factory('Siteuser')->getCurrent();
$oSiteuser && $oShop_Item_Controller->siteuser($oSiteuser);
}
//$oShop_Item_Controller->count($this->_cartQuantity);
$aPrices = $oShop_Item_Controller->getPrices($object);
$oPrices->addEntity(
Core::factory('Core_Xml_Entity')
->name('price')
->addEntity(
Core::factory('Core_Xml_Entity')
->name('value')
->value(
Shop_Controller::instance()->round($aPrices['price_discount'] * $fCurrencyCoefficient)
)
)
->addEntity(
$oShop_Currency
)
);
}
$object->addEntity($oPrices);
}
}
Core_Event::attach('shop_item.onBeforeGetXml', array('Shop_Item_Observer_Prices', 'onBeforeGetXml'));}