|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts) |
|
|
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) { |
|
|
if ($returnSelfIfNotActiveProducts) { |
|
|
return $productFamily; |
|
|
return $productFamily; |