Browse Source

ProductFamily / Product : gestion status

feature/export_comptable
Guillaume 4 years ago
parent
commit
963ae79059
4 changed files with 26 additions and 5 deletions
  1. +20
    -4
      ShopBundle/Model/ProductFamily.php
  2. +1
    -0
      ShopBundle/Repository/ProductFamilyRepository.php
  3. +4
    -0
      ShopBundle/Services/Order/OrderUtilsStockTrait.php
  4. +1
    -1
      ShopBundle/Services/ProductFamilyUtils.php

+ 20
- 4
ShopBundle/Model/ProductFamily.php View File

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;

+ 1
- 0
ShopBundle/Repository/ProductFamilyRepository.php View File

{ {
$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() ;
} }



+ 4
- 0
ShopBundle/Services/Order/OrderUtilsStockTrait.php View File



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() ;
} }

+ 1
- 1
ShopBundle/Services/ProductFamilyUtils.php View File



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];

Loading…
Cancel
Save