Skip to content

Commit

Permalink
Set stock data on variants
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed May 2, 2024
1 parent 518c8c4 commit 3f81ea7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Parser/ElasticsearchProductDocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function parse(array $document): ProductResponseInterface

// Doing this sorting here could avoid to make any DB query to get the variants in the right order just for
// getting the "default variant"
/** @var array<array-key, array{sylius-id: int|string, code: ?string, enabled: ?bool, position: int, price: array{price: ?int, original-price: ?int, applied-promotions: array}, options: array}> $sortedVariants */
/** @var array<array-key, array{sylius-id: int|string, code: ?string, enabled: ?bool, position: int, price: array{price: ?int, original-price: ?int, applied-promotions: array}, options: array, on-hand: ?int, on-hold: ?int, is-tracked: bool}> $sortedVariants */
$sortedVariants = $source['variants'];
usort(
$sortedVariants,
Expand All @@ -194,6 +194,9 @@ static function (array $a, array $b): int {
$productVariant->setCode($esVariant['code']);
$productVariant->setEnabled($esVariant['enabled']);
$productVariant->setPosition($esVariant['position']);
$productVariant->setOnHand($esVariant['on-hand']);
$productVariant->setOnHold($esVariant['on-hold']);
$productVariant->setTracked($esVariant['is-tracked']);
$this->productVariants[$esVariant['sylius-id']] = $productVariant;

$channelPricing = $this->channelPricingFactory->createNew();
Expand Down

0 comments on commit 3f81ea7

Please sign in to comment.