return $this->products; | return $this->products; | ||||
} | } | ||||
public function getProductsOnline(): Collection | |||||
{ | |||||
$products = $this->getProducts() ; | |||||
$productsOnlineArray = new ArrayCollection() ; | |||||
foreach($products as $product) { | |||||
if($product->getStatus() == 1) { | |||||
$productsOnlineArray[] = $product ; | |||||
} | |||||
} | |||||
return $productsOnlineArray ; | |||||
} | |||||
public function addProduct(ProductInterface $product): self | public function addProduct(ProductInterface $product): self | ||||
{ | { | ||||
if (!$this->products->contains($product)) { | if (!$this->products->contains($product)) { | ||||
$products = $this->getProducts(); | $products = $this->getProducts(); | ||||
foreach ($products as $product) { | foreach ($products as $product) { | ||||
$titleProduct = $product->getTitleInherited(); | |||||
if (!isset($arrayProductsGroupByTitle[$titleProduct])) { | |||||
$arrayProductsGroupByTitle[$titleProduct] = []; | |||||
if($product->getStatus() == 1) { | |||||
$titleProduct = $product->getTitleInherited(); | |||||
if (!isset($arrayProductsGroupByTitle[$titleProduct])) { | |||||
$arrayProductsGroupByTitle[$titleProduct] = []; | |||||
} | |||||
$arrayProductsGroupByTitle[$titleProduct][] = $product; | |||||
} | } | ||||
$arrayProductsGroupByTitle[$titleProduct][] = $product; | |||||
} | } | ||||
return $arrayProductsGroupByTitle; | return $arrayProductsGroupByTitle; |
{ | { | ||||
$query = $this->findByMerchantQuery() ; | $query = $this->findByMerchantQuery() ; | ||||
$query->andWhere('e.slug = :slug')->setParameter('slug',$slug) ; | $query->andWhere('e.slug = :slug')->setParameter('slug',$slug) ; | ||||
$query->andWhere('e.status = 1'); | |||||
return $query->getQuery()->getOneOrNullResult() ; | return $query->getQuery()->getOneOrNullResult() ; | ||||
} | } | ||||
public function isProductAvailable(Product $product, $quantityOrder = 0, $checkCart = false, $orderShop = null) | public function isProductAvailable(Product $product, $quantityOrder = 0, $checkCart = false, $orderShop = null) | ||||
{ | { | ||||
if($product->getStatus() != 1) { | |||||
return false ; | |||||
} | |||||
if(!$orderShop) { | if(!$orderShop) { | ||||
$orderShop = $this->getCartCurrent() ; | $orderShop = $this->getCartCurrent() ; | ||||
} | } |
private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts) | private function getCheapestOrMostExpensiveProduct($productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts) | ||||
{ | { | ||||
$products = $productFamily->getProducts()->getValues() ; | |||||
$products = $productFamily->getProductsOnline()->getValues() ; | |||||
if (count($products) > 0) { | if (count($products) > 0) { | ||||
usort($products, $comparisonFunction); | usort($products, $comparisonFunction); | ||||
return $products[0]; | return $products[0]; |