Commit 11dbe03559f8f63f4f557cf760dd3bf50ebe0ce3
1 parent
2c484508
big commti
Showing
2 changed files
with
6 additions
and
1 deletions
Show diff stats
common/modules/product/models/ProductVariant.php
@@ -137,6 +137,11 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -137,6 +137,11 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
137 | return $this->hasMany(ProductStock::className(),['product_variant_id'=> 'product_variant_id'])->joinWith('stock'); | 137 | return $this->hasMany(ProductStock::className(),['product_variant_id'=> 'product_variant_id'])->joinWith('stock'); |
138 | } | 138 | } |
139 | 139 | ||
140 | + public function getVariantActiveStocks(){ | ||
141 | + | ||
142 | + return $this->hasMany(ProductStock::className(),['product_variant_id'=> 'product_variant_id'])->where(['quantity' > 0])->joinWith('stock'); | ||
143 | + } | ||
144 | + | ||
140 | public function getStocks(){ | 145 | public function getStocks(){ |
141 | 146 | ||
142 | return $this->hasMany(Stock::className(),['stock_id'=>'stock_id']) | 147 | return $this->hasMany(Stock::className(),['stock_id'=>'stock_id']) |
frontend/views/catalog/product.php
@@ -657,7 +657,7 @@ | @@ -657,7 +657,7 @@ | ||
657 | <br/> | 657 | <br/> |
658 | <div class="shopsList"> | 658 | <div class="shopsList"> |
659 | <ul> | 659 | <ul> |
660 | - <?php foreach($product->variant->stocks as $stock){?> | 660 | + <?php foreach($product->variant->activeStock as $stock){?> |
661 | <li><?= Html::a($stock->siteName, Url::to (['text/main', 'translit' => 'magaziny', '#'=>$stock->stock_id])) ?></li> | 661 | <li><?= Html::a($stock->siteName, Url::to (['text/main', 'translit' => 'magaziny', '#'=>$stock->stock_id])) ?></li> |
662 | <?php } ?> | 662 | <?php } ?> |
663 | </ul> | 663 | </ul> |