Browse Source

Bug update productFamily prix d'export sur marché

develop
Fabien Normand 4 weeks ago
parent
commit
fc59525ff1
1 changed files with 0 additions and 68 deletions
  1. +0
    -68
      EventSubscriber/Product/UpdateProductfamilyAfterFlushEventSubscriber.php

+ 0
- 68
EventSubscriber/Product/UpdateProductfamilyAfterFlushEventSubscriber.php View File

@@ -1,68 +0,0 @@
<?php

namespace Lc\CaracoleBundle\EventSubscriber\Product;

use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class UpdateProductfamilyAfterFlushEventSubscriber implements EventSubscriberInterface
{
protected OrderShopBuilder $orderShopBuilder;
protected OpeningResolver $openingResolver;
protected FlashBagTranslator $flashBagTranslator;

public function __construct(
OrderShopBuilder $orderShopBuilder,
OpeningResolver $openingResolver,
FlashBagTranslator $flashBagTranslator
)
{
$this->orderShopBuilder = $orderShopBuilder;
$this->openingResolver = $openingResolver;
$this->flashBagTranslator = $flashBagTranslator;
}

public static function getSubscribedEvents()
{
return [
AfterEntityUpdatedEvent::class => ['processAfterFlushProductFamily'],
];
}

public function processAfterFlushProductFamily(AfterEntityUpdatedEvent $event)
{
$productFamily = $event->getEntityInstance();
if ($productFamily instanceof ProductFamilyInterface) {


foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {

$section = $productFamilySectionProperty->getSection();

if (!$this->openingResolver->isOpenSale($section)) {

$countOrderProductUpdated = $this->orderShopBuilder->updatePriceByProductFamily($productFamily, $section);

if ($countOrderProductUpdated) {
$this->flashBagTranslator->add(
'success',
'orderProductUpdated',
'OrderShop',
array(
'%count%' => $countOrderProductUpdated,
'%section%' => $section->getTitle()
)
);
}

}
}
}
}
}

Loading…
Cancel
Save