vendor/shopware/core/Content/Product/SalesChannelProductBuilder.php line 48

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product;
  3. use Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity;
  4. use Shopware\Core\Framework\Feature;
  5. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  6. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  7. /**
  8.  * @deprecated tag:v6.5.0 - Will be removed, call the AbstractPropertyGroupSorter, AbstractProductMaxPurchaseCalculator, AbstractIsNewDetector by using the respective services instead.
  9.  */
  10. class SalesChannelProductBuilder extends AbstractSalesChannelProductBuilder
  11. {
  12.     private AbstractPropertyGroupSorter $propertyGroupSorter;
  13.     private AbstractProductMaxPurchaseCalculator $maxPurchaseCalculator;
  14.     private AbstractIsNewDetector $isNewDetector;
  15.     /**
  16.      * @internal
  17.      */
  18.     public function __construct(
  19.         AbstractPropertyGroupSorter $propertyGroupSorter,
  20.         AbstractProductMaxPurchaseCalculator $maxPurchaseCalculator,
  21.         AbstractIsNewDetector $isNewDetector
  22.     ) {
  23.         $this->propertyGroupSorter $propertyGroupSorter;
  24.         $this->maxPurchaseCalculator $maxPurchaseCalculator;
  25.         $this->isNewDetector $isNewDetector;
  26.     }
  27.     public function getDecorated(): AbstractSalesChannelProductBuilder
  28.     {
  29.         Feature::triggerDeprecationOrThrow(
  30.             'v6.5.0.0',
  31.             Feature::deprecatedClassMessage(__CLASS__'v6.5.0.0''AbstractPropertyGroupSorter, AbstractProductMaxPurchaseCalculator, AbstractIsNewDetector')
  32.         );
  33.         throw new DecorationPatternException(self::class);
  34.     }
  35.     public function build(SalesChannelProductEntity $productSalesChannelContext $context): void
  36.     {
  37.         Feature::triggerDeprecationOrThrow(
  38.             'v6.5.0.0',
  39.             Feature::deprecatedClassMessage(__CLASS__'v6.5.0.0''AbstractPropertyGroupSorter, AbstractProductMaxPurchaseCalculator, AbstractIsNewDetector')
  40.         );
  41.         if (($properties $product->getProperties()) !== null) {
  42.             $product->setSortedProperties(
  43.                 $this->propertyGroupSorter->sort($properties)
  44.             );
  45.         }
  46.         $product->setCalculatedMaxPurchase(
  47.             $this->maxPurchaseCalculator->calculate($product$context)
  48.         );
  49.         $product->setIsNew(
  50.             $this->isNewDetector->isNew($product$context)
  51.         );
  52.     }
  53. }