Skip to content

Commit

Permalink
Added more logs to akeneo category attributes import
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Aug 21, 2024
1 parent bfd81ab commit 155f4d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 24 additions & 2 deletions src/Processor/Category/AttributeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function getDefaultPriority(): int
}

public function __construct(
private LoggerInterface $logger,
private LoggerInterface $akeneoLogger,
private EntityManagerInterface $entityManager,
private RepositoryInterface $taxonAttributeRepository,
private RepositoryInterface $taxonAttributeValueRepository,
Expand All @@ -44,6 +44,14 @@ public function process(TaxonInterface $taxon, array $resource): void
{
foreach ($resource['values'] as $attributeValue) {
try {
$this->akeneoLogger->info('Processing category attribute for taxon', [
'taxon' => $taxon->getCode(),
'attribute' => $attributeValue,
'type' => $attributeValue['type'],
'locale' => $attributeValue['locale'],
'channel' => $attributeValue['channel'],
]);

$taxonAttribute = $this->getTaxonAttributes(
$attributeValue['attribute_code'],
$attributeValue['type'],
Expand All @@ -57,14 +65,19 @@ public function process(TaxonInterface $taxon, array $resource): void
$attributeValue['data'],
);

$this->akeneoLogger->info('Set TaxonAttribute value', [
'code' => $attributeValue['attribute_code'],
'value' => $value,
]);

$this->getTaxonAttributeValues(
$attributeValue,
$taxon,
$taxonAttribute,
$value,
);
} catch (ExcludedAttributeException|UnsupportedAttributeTypeException $e) {
$this->logger->warning($e->getMessage(), [
$this->akeneoLogger->warning($e->getMessage(), [
'trace' => $e->getTrace(),
'exception' => $e,
]);
Expand All @@ -82,6 +95,11 @@ private function getTaxonAttributes(string $attributeCode, string $type): TaxonA
$taxonAttribute = $this->taxonAttributeRepository->findOneBy(['code' => $attributeCode]);

if ($taxonAttribute instanceof TaxonAttribute) {
$this->akeneoLogger->debug('Found TaxonAttribute', [
'code' => $attributeCode,
'type' => $type,
]);

return $taxonAttribute;
}

Expand All @@ -95,6 +113,10 @@ private function getTaxonAttributes(string $attributeCode, string $type): TaxonA
$taxonAttribute->setTranslatable(false);

$this->entityManager->persist($taxonAttribute);
$this->akeneoLogger->debug('Created TaxonAttribute', [
'code' => $attributeCode,
'type' => $type,
]);

return $taxonAttribute;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Synolia\SyliusAkeneoPlugin\Event\Category\AfterProcessingTaxonEvent;
use Synolia\SyliusAkeneoPlugin\Event\Category\BeforeProcessingTaxonEvent;
use Synolia\SyliusAkeneoPlugin\Exceptions\Attribute\ExcludedAttributeException;
use Synolia\SyliusAkeneoPlugin\Manager\Doctrine\DoctrineSortableManager;
use Synolia\SyliusAkeneoPlugin\Processor\Category\CategoryProcessorChainInterface;
use Synolia\SyliusAkeneoPlugin\Processor\Resource\AkeneoResourceProcessorInterface;
Expand Down

0 comments on commit 155f4d5

Please sign in to comment.