Quellcode durchsuchen

ProductFamily / Product : gestion status

feature/export_comptable
Guillaume vor 4 Jahren
Ursprung
Commit
963ae79059
4 geänderte Dateien mit 26 neuen und 5 gelöschten Zeilen
  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 Datei anzeigen

@@ -321,6 +321,20 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
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
{
if (!$this->products->contains($product)) {
@@ -759,11 +773,13 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
$products = $this->getProducts();

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;

+ 1
- 0
ShopBundle/Repository/ProductFamilyRepository.php Datei anzeigen

@@ -40,6 +40,7 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
{
$query = $this->findByMerchantQuery() ;
$query->andWhere('e.slug = :slug')->setParameter('slug',$slug) ;
$query->andWhere('e.status = 1');
return $query->getQuery()->getOneOrNullResult() ;
}


+ 4
- 0
ShopBundle/Services/Order/OrderUtilsStockTrait.php Datei anzeigen

@@ -59,6 +59,10 @@ trait OrderUtilsStockTrait

public function isProductAvailable(Product $product, $quantityOrder = 0, $checkCart = false, $orderShop = null)
{
if($product->getStatus() != 1) {
return false ;
}

if(!$orderShop) {
$orderShop = $this->getCartCurrent() ;
}

+ 1
- 1
ShopBundle/Services/ProductFamilyUtils.php Datei anzeigen

@@ -40,7 +40,7 @@ class ProductFamilyUtils

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

Laden…
Abbrechen
Speichern