Skip to content

Commit

Permalink
use cache when retrieving family variation axes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Jun 12, 2024
1 parent f432984 commit da0450d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Processor/ProductGroup/FamilyVariationAxeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Synolia\SyliusAkeneoPlugin\Processor\ProductGroup;

use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
use Psr\Log\LoggerInterface;
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
use Synolia\SyliusAkeneoPlugin\Entity\ProductGroup;
use Synolia\SyliusAkeneoPlugin\Entity\ProductGroupInterface;
use Synolia\SyliusAkeneoPlugin\Retriever\FamilyRetrieverInterface;
use Synolia\SyliusAkeneoPlugin\Retriever\FamilyVariantRetrieverInterface;

final class FamilyVariationAxeProcessor
{
Expand All @@ -18,9 +18,9 @@ final class FamilyVariationAxeProcessor
private array $familyVariants;

public function __construct(
private AkeneoPimClientInterface $akeneoPimEnterpriseClient,
private EntityRepository $productGroupRepository,
private FamilyRetrieverInterface $familyRetriever,
private FamilyVariantRetrieverInterface $familyVariantRetriever,
private LoggerInterface $logger,
) {
$this->familyVariants = [];
Expand All @@ -47,10 +47,7 @@ public function process(array $resource): void
$family = $family ?: $resource['family'];

if (!isset($this->familyVariants[$family][$resource['family_variant']])) {
$payloadProductGroup = $this->akeneoPimEnterpriseClient->getFamilyVariantApi()->get(
$family,
$resource['family_variant'],
);
$payloadProductGroup = $this->familyVariantRetriever->getVariant($family, $resource['family_variant']);

$this->familyVariants[$family][$resource['family_variant']] = $payloadProductGroup;
}
Expand Down

0 comments on commit da0450d

Please sign in to comment.