Skip to content

Instantly share code, notes, and snippets.

@r3code
Last active October 31, 2017 20:16
Show Gist options
  • Save r3code/f0714d32dc689f6e26f9d1747f10a93f to your computer and use it in GitHub Desktop.
Save r3code/f0714d32dc689f6e26f9d1747f10a93f to your computer and use it in GitHub Desktop.
HostCMS 5 - Горячие предложения (блок в макете)
<?php // Горячие предложения / расчет (вставить сверху шаблона)
if (class_exists('shop'))
{
$shop = & singleton('shop');
$shop_id = 1;
$param_offer = array();
// Товары выбираем из всех групп
$param_offer['current_group_id'] = false;
// Выводим по 4 товара в блока
$param_offer['items_on_page'] = 4;
// Используем случайный вывод товара
$param_offer['items_order'] = 'rand';
// Получаем все скидки магазина
$has_hotoffers = false;
$AllDiscount = $shop->GetAllDiscounts($shop_id, array('shop_discount_is_active' => 1, 'shop_discount_is_hold' => true));
// Скидки есть
if ($AllDiscount)
{
$param_offer['select_discount'] = array();
// Цикл по полученным скидкам
while ($row = mysql_fetch_assoc($AllDiscount))
{
// В массив добавляем идентификаторы скидок
$param_offer['select_discount'][] = $row['shop_discount_id'];
}
if ( count($param_offer['select_discount']) > 0 ) {
$has_hotoffers = true;
}
}
// Вывод только из активных групп, при необходимости раскомментировать
$param_offer['current_group_id'] = array(0);
$aGroups = $shop->GetAllGroups($shop_id, array('groups_activity' => 1));
if (is_array($aGroups) && count($aGroups) > 0)
{
foreach ($aGroups as $aGroupRow)
{
$param_offer['current_group_id'][] = $aGroupRow['shop_groups_id'];
}
}
}
?>
<!-- Тело страницы -->
<?php // Горячие предложения / вывод (вставить в то место, где нужно выводить блок)
if (class_exists('shop') and $has_hotoffers)
{
$shop->ShowShop($shop_id, 'МагазинГорячиеПредложения', $param_offer);
}
?>
<!--
// Создать в системе
// XSLT-шаблон "МагазинГорячиеПредложения"
// текст шаблона см. https://gist.github.com/r3code/bce93bae489be4e19215d947925a339f
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment