Kaynağa Gözat

[backend] Correction bug cast Product dans méthode linkProduct

refactoring
Guillaume Bourgeois 5 yıl önce
ebeveyn
işleme
b38422ec7f
2 değiştirilmiş dosya ile 6 ekleme ve 7 silme
  1. +4
    -5
      backend/controllers/DistributionController.php
  2. +2
    -2
      common/models/Distribution.php

+ 4
- 5
backend/controllers/DistributionController.php Dosyayı Görüntüle

@@ -160,13 +160,15 @@ class DistributionController extends BackendController
$potentialRevenues = 0;
$potentialWeight = 0;
foreach($productsArray as &$theProduct) {
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ;
$theProduct['quantity_ordered'] = $quantityOrder ;
if(!isset($theProduct['productDistribution'][0])) {
$theProduct['productDistribution'][0] = $distribution->linkProduct($theProduct) ;
$theProductObject = (object) $theProduct ;
$theProduct['productDistribution'][0] = $distribution->linkProduct($theProductObject) ;
}
if(!is_numeric($theProduct['productDistribution'][0]['quantity_max'])) {
@@ -200,9 +202,6 @@ class DistributionController extends BackendController
] ;
}
/*$productOrderArray = \yii\helpers\ArrayHelper::map($order->productOrder, 'id_product', 'quantity') ;
*/
foreach($productsArray as $product) {
if(!isset($productOrderArray[$product['id']])) {
$productOrderArray[$product['id']] = [

+ 2
- 2
common/models/Distribution.php Dosyayı Görüntüle

@@ -242,12 +242,12 @@ class Distribution extends ActiveRecordCommon
* @param Product $product
*/
public function linkProduct($product)
{
{
$productDistribution = ProductDistribution::searchOne([
'id_distribution' => $this->id,
'id_product' => $product->id
]) ;
if(!$productDistribution) {
$productDistribution = new ProductDistribution();
$productDistribution->id_distribution = $this->id;

Yükleniyor…
İptal
Kaydet