ソースを参照

Merge branch 'develop'

master
Guillaume 3年前
コミット
3422fdeccf
5個のファイルの変更59行の追加38行の削除
  1. +2
    -0
      Container/Product/ProductContainer.php
  2. +33
    -37
      EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php
  3. +1
    -1
      Model/Site/PageModel.php
  4. +13
    -0
      Repository/Product/ProductRepositoryQuery.php
  5. +10
    -0
      Repository/Product/ProductStore.php

+ 2
- 0
Container/Product/ProductContainer.php ファイルの表示

@@ -48,4 +48,6 @@ class ProductContainer
return $this->store;
}



}

+ 33
- 37
EventSubscriber/Product/UpdateProductfamilyEventSubscriber.php ファイルの表示

@@ -78,50 +78,46 @@ class UpdateProductfamilyEventSubscriber implements EventSubscriberInterface
protected function processProducts($entity)
{

//Récupère le product origin
$originProducts = $this->em->getRepository(ProductInterface::class)
->findBy(
array(
'productFamily' => $entity->getId(),
'originProduct' => true,
)
);

if (count($originProducts) > 1) {
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab');
// Case Nouveau product family
} else {
if (count($originProducts) == 0) {
$entityClassName = $this->em->getEntityName(ProductInterface::class);
$originProduct = new $entityClassName();
$originProduct->setProductFamily($entity);
$originProduct->setOriginProduct(true);
$entity->addProduct($originProduct);
if($entity->getId()) {
//Récupère le product origin
$originProducts = $this->productContainer->getStore()->getOriginByProductFamily($entity);

if (count($originProducts) > 1) {
throw new \ErrorException('Plusieurs OriginProduct pour un même produit... Contacter fab');
// Case Nouveau product family
} else {
$originProduct = $originProducts[0];
if (count($originProducts) == 0) {
$entityClassName = $this->em->getEntityName(ProductInterface::class);
$originProduct = new $entityClassName();
$originProduct->setProductFamily($entity);
$originProduct->setOriginProduct(true);
$entity->addProduct($originProduct);
} else {
$originProduct = $originProducts[0];
}
}
}

if ($entity->getActiveProducts()) {
$originProduct->setStatus(-1);
} else {
$originProduct->setStatus(1);
}
if ($entity->getActiveProducts()) {
$originProduct->setStatus(-1);
} else {
$originProduct->setStatus(1);
}

//Enregistrement
$entity->addProduct($originProduct);
//Enregistrement
$entity->addProduct($originProduct);

foreach ($entity->getProducts() as $product) {
$product->setProductFamily($entity);
foreach ($entity->getProducts() as $product) {
$product->setProductFamily($entity);

if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) {
$product->setTitle(
str_replace('.', ',', $this->productContainer->getSolver()->getQuantityInherited($product)) . $this->productContainer->getSolver()->getUnitInherited($product)->getWording()
);
}
if ($entity->getProductsQuantityAsTitle() && $product->getStatus() >= 1) {
$product->setTitle(
str_replace('.', ',', $this->productContainer->getSolver()->getQuantityInherited($product)) . $this->productContainer->getSolver()->getUnitInherited($product)->getWording()
);
}

$this->em->persist($product);
$entity->addProduct($product);
$this->em->persist($product);
$entity->addProduct($product);
}
}
}


+ 1
- 1
Model/Site/PageModel.php ファイルの表示

@@ -43,7 +43,7 @@ abstract class PageModel extends SovPageModel implements FilterMerchantInterface
return $this->section;
}

public function setSection(SectionInterface $section): self
public function setSection(?SectionInterface $section): self
{
$this->section = $section;


+ 13
- 0
Repository/Product/ProductRepositoryQuery.php ファイルの表示

@@ -95,6 +95,19 @@ class ProductRepositoryQuery extends AbstractRepositoryQuery
}


public function filterIsOriginProduct():self
{
$this->andWhere('.originProduct = 1');
return $this;
}


public function filterByProductFamily(ProductFamilyInterface $productFamily): self
{
return $this->andWhereEqual('productFamily', $productFamily);
}


public function filterAvailableQuantityNegative() :self
{


+ 10
- 0
Repository/Product/ProductStore.php ファイルの表示

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Repository\Product;

use App\Entity\Product\ProductFamily;
use App\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
@@ -77,4 +78,13 @@ class ProductStore extends AbstractStore
}


public function getOriginByProductFamily(ProductFamily $productFamily, ProductRepositoryQuery $query = null): array
{
$query = $this->createQuery();
$query->filterByProductFamily($productFamily);
$query->filterIsOriginProduct();
$query->filterIsOnlineAndOffline();
return $query->find();

}
}

読み込み中…
キャンセル
保存