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

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