-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da0450d
commit 4da43a3
Showing
42 changed files
with
707 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\Command; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface; | ||
use Synolia\SyliusAkeneoPlugin\Payload\Category\CategoryPayload; | ||
use Synolia\SyliusAkeneoPlugin\Task\Category\BatchCategoriesTask; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class BatchImportCategoriesCommand extends AbstractBatchCommand | ||
{ | ||
protected static $defaultDescription = 'Import batch categories ids from Akeneo PIM.'; | ||
|
||
/** @var string */ | ||
protected static $defaultName = 'akeneo:batch:categories'; | ||
|
||
public function __construct( | ||
private ClientFactoryInterface $clientFactory, | ||
private LoggerInterface $logger, | ||
private BatchCategoriesTask $task, | ||
) { | ||
parent::__construct(self::$defaultName); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute( | ||
InputInterface $input, | ||
OutputInterface $output, | ||
) { | ||
Assert::string($input->getArgument('ids')); | ||
$ids = explode(',', $input->getArgument('ids')); | ||
|
||
$this->logger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]); | ||
$this->logger->debug(self::$defaultName, ['batched_ids' => $ids]); | ||
|
||
$payload = new CategoryPayload($this->clientFactory->createFromApiCredentials()); | ||
$payload->setIds($ids); | ||
|
||
$this->task->__invoke($payload); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\Message\Batch; | ||
|
||
class CategoryBatchMessage implements BatchMessageInterface | ||
{ | ||
public function __construct(public array $items) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\MessageHandler\Batch; | ||
|
||
use Symfony\Component\Messenger\Attribute\AsMessageHandler; | ||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; | ||
use Synolia\SyliusAkeneoPlugin\Message\Batch\CategoryBatchMessage; | ||
use Synolia\SyliusAkeneoPlugin\Processor\Resource\Category\CategoryResourceProcessor; | ||
use Synolia\SyliusAkeneoPlugin\Processor\Resource\Exception\MaxResourceProcessorRetryException; | ||
|
||
#[AsMessageHandler] | ||
class CategoryBatchMessageHandler | ||
{ | ||
public function __construct( | ||
private EventDispatcherInterface $dispatcher, | ||
private CategoryResourceProcessor $resourceProcessor, | ||
) { | ||
} | ||
|
||
public function __invoke(CategoryBatchMessage $attributeBatchMessage): void | ||
{ | ||
foreach ($attributeBatchMessage->items as $resource) { | ||
try { | ||
$this->resourceProcessor->process($resource); | ||
} catch (MaxResourceProcessorRetryException) { | ||
// Skip the failing line | ||
$this->dispatcher->dispatch(new CategoryBatchMessage([$resource])); | ||
|
||
continue; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.