Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Event/Product/PostFlushEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Synolia\SyliusAkeneoPlugin\Event\Product;

use Sylius\Component\Core\Model\ProductInterface;
use Synolia\SyliusAkeneoPlugin\Event\AbstractResourceEvent;

class PostFlushEvent extends AbstractResourceEvent
{
public function __construct(array $resource, private ProductInterface $product)
{
parent::__construct($resource);
}

public function getProduct(): ProductInterface
{
return $this->product;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Synolia\SyliusAkeneoPlugin\Checker\Product\IsProductProcessableCheckerInterface;
use Synolia\SyliusAkeneoPlugin\Event\Product\AfterProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Event\Product\BeforeProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Event\Product\PostFlushEvent;
use Synolia\SyliusAkeneoPlugin\Processor\Product\ProductProcessorChainInterface;
use Synolia\SyliusAkeneoPlugin\Processor\ProductGroup\ProductGroupProcessor;
use Synolia\SyliusAkeneoPlugin\Processor\Resource\AkeneoResourceProcessorInterface;
Expand Down Expand Up @@ -66,6 +67,7 @@ public function process(array $resource): void

$this->dispatcher->dispatch(new AfterProcessingProductEvent($resource, $product));
$this->entityManager->flush();
$this->dispatcher->dispatch(new PostFlushEvent($resource, $product));
} catch (ORMInvalidArgumentException $ormInvalidArgumentException) {
++$this->retryCount;
usleep($this->retryWaitTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Synolia\SyliusAkeneoPlugin\Event\Product\AfterProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Event\Product\BeforeProcessingProductEvent;
use Synolia\SyliusAkeneoPlugin\Event\Product\PostFlushEvent;
use Synolia\SyliusAkeneoPlugin\Event\ProductVariant\AfterProcessingProductVariantEvent;
use Synolia\SyliusAkeneoPlugin\Event\ProductVariant\BeforeProcessingProductVariantEvent;
use Synolia\SyliusAkeneoPlugin\Processor\Product\ProductProcessorChainInterface;
Expand Down Expand Up @@ -91,8 +92,9 @@ public function process(array $resource): void

$product = $this->getOrCreateEntity($resource);
$this->productProcessorChain->chain($product, $resource);

$this->dispatcher->dispatch(new AfterProcessingProductEvent($resource, $product));
$this->entityManager->flush();
$this->dispatcher->dispatch(new PostFlushEvent($resource, $product));

$this->dispatcher->dispatch(new BeforeProcessingProductVariantEvent($resource, $product));

Expand Down
Loading