Commit 424c7cdcd06438b4ea5757b718b3315030a073aa
1 parent
b8af7493
Ntr
Showing
2 changed files
with
6 additions
and
1 deletions
Show diff stats
common/modules/product/models/Import.php
@@ -169,6 +169,12 @@ class Import extends Model { | @@ -169,6 +169,12 @@ class Import extends Model { | ||
169 | $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count; | 169 | $quantity = array_sum(ArrayHelper::getColumn($productStocks, 'quantity')) + $count; |
170 | } else { | 170 | } else { |
171 | $quantity = 0; | 171 | $quantity = 0; |
172 | + $productStocks = new ProductStock(); | ||
173 | + $productStocks->product_id = $productVariant->product_id; | ||
174 | + $productStocks->quantity = $quantity; | ||
175 | + $productStocks->product_variant_id = $productVariant->product_variant_id; | ||
176 | + $productStocks->save(); | ||
177 | + | ||
172 | } | 178 | } |
173 | 179 | ||
174 | } | 180 | } |
common/modules/product/models/ProductStock.php
@@ -33,7 +33,6 @@ class ProductStock extends \yii\db\ActiveRecord | @@ -33,7 +33,6 @@ class ProductStock extends \yii\db\ActiveRecord | ||
33 | { | 33 | { |
34 | return [ | 34 | return [ |
35 | [['product_id', 'stock_id', 'quantity', 'product_variant_id'], 'integer'], | 35 | [['product_id', 'stock_id', 'quantity', 'product_variant_id'], 'integer'], |
36 | - [['name'],'required'], | ||
37 | [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | 36 | [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], |
38 | [['product_variant_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['product_variant_id' => 'product_variant_id']], | 37 | [['product_variant_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductVariant::className(), 'targetAttribute' => ['product_variant_id' => 'product_variant_id']], |
39 | [['stock_id'], 'exist', 'skipOnError' => true, 'targetClass' => Stock::className(), 'targetAttribute' => ['stock_id' => 'stock_id']], | 38 | [['stock_id'], 'exist', 'skipOnError' => true, 'targetClass' => Stock::className(), 'targetAttribute' => ['stock_id' => 'stock_id']], |