Skip to content

Commit

Permalink
don't crash import on asset error
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Sep 12, 2024
1 parent 4739488 commit 00a7478
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Processor/ProductAttribute/AssetAttributeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Synolia\SyliusAkeneoPlugin\Processor\ProductAttribute;

use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
use Akeneo\Pim\ApiClient\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Core\Model\ProductInterface;
Expand Down Expand Up @@ -128,8 +129,18 @@ public function process(string $attributeCode, array $context = []): void

foreach ($context['data'] as $assetCodes) {
foreach ($assetCodes['data'] as $assetCode) {
$assetResource = $this->akeneoPimClient->getAssetManagerApi()->get($attributeCode, $assetCode);
$this->handleAssetByFamilyResource($context['model'], $attributeCode, $assetResource);
try {
$assetResource = $this->akeneoPimClient->getAssetManagerApi()->get($attributeCode, $assetCode);
$this->handleAssetByFamilyResource($context['model'], $attributeCode, $assetResource);
} catch (RuntimeException $runtimeException) {
$this->logger->error('Error processing asset', [
'product' => $context['model']->getCode(),
'asset_code' => $assetCode,
'exception_code' => $runtimeException->getCode(),
'exception_message' => $runtimeException->getMessage(),
'exception_trace' => $runtimeException->getTraceAsString(),
]);
}
}
}
}
Expand Down

0 comments on commit 00a7478

Please sign in to comment.