Browse Source

Implémentation OrginProduct

feature/export_comptable
Fab 4 years ago
parent
commit
03efa732c2
2 changed files with 19 additions and 4 deletions
  1. +11
    -0
      ShopBundle/Model/ProductFamily.php
  2. +8
    -4
      ShopBundle/Services/ProductFamilyUtils.php

+ 11
- 0
ShopBundle/Model/ProductFamily.php View File

@@ -802,4 +802,15 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
}
}
}

public function getOriginProductOnline()
{
$originProduct = $this->getOriginProduct() ;

if($originProduct->getStatus()==1){
return $originProduct;
}else{
return false;
}
}
}

+ 8
- 4
ShopBundle/Services/ProductFamilyUtils.php View File

@@ -40,10 +40,14 @@ class ProductFamilyUtils

private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts)
{
$products = $productFamily->getProductsOnline()->getValues() ;
if (count($products) > 0) {
usort($products, $comparisonFunction);
return $products[0];
if($productFamily->getActiveProducts()) {
$products = $productFamily->getProductsOnline()->getValues();
if (count($products) > 0) {
usort($products, $comparisonFunction);
return $products[0];
}
}else{
return $productFamily->getOriginProduct();
}
if ($returnSelfIfNotActiveProducts) {
return $productFamily;

Loading…
Cancel
Save