vendor/shopware/storefront/Page/Product/Configurator/ProductCombinationFinder.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Page\Product\Configurator;
  3. use Shopware\Core\Content\Product\Exception\ProductNotFoundException;
  4. use Shopware\Core\Content\Product\SalesChannel\FindVariant\FindProductVariantRoute;
  5. use Shopware\Core\Framework\Feature;
  6. use Shopware\Core\Framework\Log\Package;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. use Symfony\Component\HttpFoundation\Request;
  9. /**
  10.  * @deprecated tag:v6.5.0 - Class will be removed, use \Shopware\Core\Content\Product\SalesChannel\FindVariant\FindProductVariantRoute instead
  11.  */
  12. #[Package('inventory')]
  13. class ProductCombinationFinder
  14. {
  15.     private FindProductVariantRoute $findVariantRoute;
  16.     /**
  17.      * @internal
  18.      */
  19.     public function __construct(FindProductVariantRoute $findVariantRoute)
  20.     {
  21.         $this->findVariantRoute $findVariantRoute;
  22.     }
  23.     /**
  24.      * @throws ProductNotFoundException
  25.      */
  26.     public function find(string $productId, ?string $wishedGroupId, array $optionsSalesChannelContext $salesChannelContext): FoundCombination
  27.     {
  28.         Feature::triggerDeprecationOrThrow(
  29.             'v6.5.0.0',
  30.             Feature::deprecatedClassMessage(__CLASS__'v6.5.0.0'FindProductVariantRoute::class)
  31.         );
  32.         $result $this->findVariantRoute->load(
  33.             $productId,
  34.             new Request(
  35.                 [
  36.                     'switchedGroup' => $wishedGroupId,
  37.                     'options' => $options,
  38.                 ]
  39.             ),
  40.             $salesChannelContext
  41.         );
  42.         return new FoundCombination($result->getFoundCombination()->getVariantId(), $result->getFoundCombination()->getOptions());
  43.     }
  44. }