Skip to content

Commit

Permalink
Check if we can reset before doing it
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Sep 10, 2024
1 parent 89e13f0 commit df0662a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/EventListener/Doctrine/ProductListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ private function handle(LifecycleEventArgs $eventArgs): void
Assert::isInstanceOf($variant, ProductVariantInterface::class);

$uploadProductVariantRequest = $variant->getPeakUploadProductVariantRequest() ?? $this->uploadProductVariantRequestFactory->createNew();
$this->uploadProductVariantRequestWorkflow->apply($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_RESET);

if ($this->uploadProductVariantRequestWorkflow->can($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_RESET)) {
$this->uploadProductVariantRequestWorkflow->apply(
$uploadProductVariantRequest,
UploadProductVariantRequestWorkflow::TRANSITION_RESET,
);
}

$variant->setPeakUploadProductVariantRequest($uploadProductVariantRequest);
}
Expand Down

0 comments on commit df0662a

Please sign in to comment.