view->title='DuneRealms Shop'; $rows=Yii::$app->db->createCommand("SELECT p.products_id,p.products_price,p.products_tax_class_id,pd.products_name,pd.products_description_short,d.kind FROM products p JOIN platforms_products pp ON pp.products_id=p.products_id AND pp.platform_id=7 JOIN products_description pd ON pd.products_id=p.products_id AND pd.language_id=1 AND pd.platform_id=7 LEFT JOIN dune_catalog_import d ON d.products_id=p.products_id WHERE p.products_status=1 ORDER BY p.products_date_added DESC,p.products_id DESC")->queryAll(); $saleIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM specials WHERE EXISTS(SELECT 1 FROM products active JOIN platforms_products pp ON pp.products_id=active.products_id AND pp.platform_id=7 WHERE active.products_id=specials.products_id AND active.products_status=1 AND specials.specials_new_products_priceNOW())")->queryColumn(); $featuredIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM featured WHERE EXISTS(SELECT 1 FROM products active JOIN platforms_products pp ON pp.products_id=active.products_id AND pp.platform_id=7 WHERE active.products_id=featured.products_id AND active.products_status=1) AND status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); $sashes=count(array_filter($rows,fn($r)=>$r['kind']==='sash'));$ranks=count(array_filter($rows,fn($r)=>$r['kind']==='rank')); $base=fn($route)=>Html::encode(\yii\helpers\Url::to([$route])); $out='
THE DUNEREALMS EMPORIUM

Carry a piece of the realms.

Ceremonial sashes, personal keepsakes and ways to support the community.

Browse the collection
'; $tiles=[['Sale',count($saleIds)?'Explore current offers':'No sales active right now','catalog/sales','nav-exchange-v2.webp',''],['Ceremonial sashes',$sashes.' designs · made to order','catalog/all-products','nav-clan-v2.webp','sash'],['Donor ranks',$ranks.' ways to support the realms','catalog/all-products','nav-account-v2.webp','rank']]; $out.=''; foreach([['Sale','Current offers from the emporium',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$saleIds))),'catalog/sales'],['Featured','Selected pieces from the realms',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$featuredIds))),'catalog/featured-products'],['New arrivals','Recently added to the collection',array_slice($rows,0,6),'catalog/products-new']] as [$title,$sub,$items,$route]){ $out.='

'.($title==='Sale'?'SALE ':'').$title.'

'.$sub.'

View all ↗
'; if(!$items)$out.='
'.($title==='Sale'?'There are no active sale offers.':'Featured products have not been selected yet.').'
'; else{ $out.='
'; foreach(array_slice($items,0,6) as $p){ $url=Html::encode(\yii\helpers\Url::to(['catalog/product','products_id'=>$p['products_id']])); $image=Html::encode(\common\classes\Images::getImageUrl($p['products_id'],'Small',1)); $currencies=Yii::$container->get('currencies');$tax=\common\helpers\Tax::get_tax_rate($p['products_tax_class_id']); $normal=\common\helpers\Product::get_products_price($p['products_id'],1,$p['products_price']); $special=\common\helpers\Product::get_products_special_price($p['products_id'],1); $price=$currencies->display_price($normal,$tax); if($special!==false&&$special!==null&&(float)$special>=0&&(float)$special<(float)$normal){ $saving=(int)round((1-(float)$special/(float)$normal)*100); $price=''.$price.''.$currencies->display_price($special,$tax).'Save '.$saving.'%'; } $out.=''; } $out.='
'; } $out.='
'; } $out.=''; return $this->renderContent($out); } }