Beispiel #1
0
 /**
  * @param $slug
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionView($slug)
 {
     $category = Catalog::cat($slug);
     if (!$category) {
         throw new NotFoundHttpException();
     }
     return $this->render('/category/view', ['category' => $category, 'page' => Shop::page('catalog')]);
 }
Beispiel #2
0
 /**
  * @param $product_id
  */
 public function add($product_id)
 {
     $product = Catalog::product($product_id);
     if ($product) {
         $this->items[$product_id] = ['name' => $product->model->name];
     }
     $this->save();
 }
Beispiel #3
0
 /**
  * @param $productId
  * @param int $quantity
  */
 public function add($productId, $quantity = 1)
 {
     if (isset($this->lines[$productId])) {
         $this->lines[$productId]->quantity += $quantity;
     } else {
         $product = Catalog::product($productId);
         if (!$product) {
             throw new InvalidParamException("Product with id = {$productId} does not exist");
         }
         $this->lines[$productId] = new CartLine(['product_id' => $productId, 'price' => $product->model->price, 'quantity' => $quantity]);
     }
     $this->save();
 }
Beispiel #4
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     return $this->render('index', ['new_products' => Catalog::new_products(), 'page' => Shop::page(Pages::HOME_PAGE)]);
 }
Beispiel #5
0
        <div class="row">
            <div class="col-md-3">
                <div class="thumbnail no-border">
                    <?php 
echo Html::img($page->getImageUrl());
?>
                </div>
            </div>
            <div class="col-md-9">
                <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
                <div class="announce">
                    <h1><?php 
echo Html::encode($page->model->name);
?>
</h1>
                    <p><?php 
echo $page->model->announce;
?>
</p>
                </div>
            </div>
        </div>
    </div>
    <div class="bordered">
        <?php 
echo $this->render('_list', ['categories' => $categories, 'pager' => Catalog::pager()]);
?>
    </div>
</div>
Beispiel #6
0
 /**
  * @return Product
  */
 public function getProduct()
 {
     return Catalog::product($this->product_id);
 }
Beispiel #7
0
    <div class="row">
        <div class="col-md-12">
            <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
            <div class="header">
                <h1><?php 
echo $this->title;
?>
</h1>
                <p><?php 
echo $page->announce;
?>
</p>
            </div>
        </div>
    </div>
    <div class="link-sorter">
        <span class="caption"><?php 
echo Yii::t('app', 'Order by:');
?>
</span><?php 
echo Catalog::sorter();
?>
    </div>
    <div class="bordered">
        <?php 
echo $this->render('/product/_list', ['products' => $products, 'pager' => Catalog::pager()]);
?>
    </div>
</div>
Beispiel #8
0
    <table class="table">
        <thead>
            <tr>
                <th class="thumb-mini"></th>
                <th class="name"><?php 
    echo Yii::t('app', 'Product name');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
        <?php 
    foreach ($wishList->items as $id => $item) {
        ?>
            <?php 
        $product = Catalog::product($id);
        ?>
            <?php 
        if ($product) {
            ?>
            <tr>
                <td class="thumb-mini">
                    <a href="<?php 
            echo Url::to(['/product/view', 'slug' => $product->model->slug]);
            ?>
">
                        <?php 
            echo Html::img($product->thumb(64, 64));
            ?>
                    </a>
                </td>
Beispiel #9
0
 /**
  * @param $q
  * @return string
  */
 public function actionSearch($q)
 {
     $products = Catalog::search(trim($q), ['sort' => ['attributes' => ['name', 'price', 'rating']]]);
     return $this->render('search', ['products' => $products, 'page' => Shop::page(Pages::SEARCH_RESULTS)]);
 }