$m_return = '';
$L = Core_Language::getInstance();
$products = new Products();
$lang = $L->getCurrentLanguage();
$goods_list_page = '/'.$lang.'/shop/';
if(!empty($seo_page['categories'])) {
foreach($seo_page['categories'] as $cat_item) {
$parentid = $cat_item['id'];
$list = $cats->getList($cat_item['id'], 'active');
if (!empty($list)) {
$m_return .= '
';
if(isset($cat_item['id']))
$m_return .= '
'.$L->StrT('goods_categories','title', $cat_item['id'], $cat_item['title']).'
';
foreach ($list as $item) {
$pic = $item['image'] ? '/images/category/'.$item['image'] : 'nopic.jpg';
$l = $cats -> getPath($item['id'], 'sef',$lang,'',$parentid);
$l = implode('/',$l);
$link = $goods_list_page.$l.'/';
$m_return .= '
';
}
$m_return .= '
';
} else {
//$fields['id'] = $products ->getProductsTop(5,31,$cat_item['id']);
//$topGoods = $products->getList($fields);
$fields['id'] = $products ->getCategorySales(5,31,$cat_item['id']);
if(!empty($fields['id']) && count($fields['id'])>=5) {
$salesGoods = $products->getList($fields);
$top=1;
} else {
$fields = array();
$fields['catid'] = $cat_item['id'];
$salesGoods = $products->getList($fields,$params = array('offset'=>'0','length'=>5));
$top=0;
}
$m_return .=''.$L->StrT('goods_categories','title', $cat_item['id'], $cat_item['title']).'
';
$m_return .= '';
$item = $cat_item;
$pic = $cat_item['image'] ? '/images/category/'.$cat_item['image'] : 'nopic.jpg';
$l = $cats -> getPath($cat_item['id'], 'sef',$lang,'',$cat_item['parentid']);
$l = implode('/',$l);
$link = $goods_list_page.$l.'/';
$m_return .= '
';
$m_return .= '
';
$m_return .= '';
if(!empty($salesGoods['data']))
foreach($salesGoods['data'] as $item) {
//print_r($item);
$thumb = $products->getThumbnail($item['id'],'t');
$link = $products -> getLink($item['id']);
$title= htmlspecialchars($L->StrT('goods','title', $item['id'], $item['title']));
//if($top==1 $title .=' top';
//$title = $item['title'];
$m_return .= '
'.$item['price_2'].' EUR
-'.$item['discount'].'%
';
}
$m_return .='
';
$m_return .='
';
}
}
}