@@ -30,26 +30,36 @@ class ProductPriceListener
3030 /** @var ProductRepository */
3131 protected $ productRepository ;
3232
33+ /** @var array */
34+ protected $ trackedPriceTypes ;
35+
3336 /**
3437 * @param ProductChangesByChannelStack $productChangesStack
3538 * @param TrackedSalesChannelProvider $salesChannelProvider
3639 * @param ProductRepository $productRepository
40+ * @param array $trackedPriceTypes
3741 */
3842 public function __construct (
3943 ProductChangesByChannelStack $ productChangesStack ,
4044 TrackedSalesChannelProvider $ salesChannelProvider ,
41- ProductRepository $ productRepository
45+ ProductRepository $ productRepository ,
46+ array $ trackedPriceTypes
4247 ) {
4348 $ this ->productChangesStack = $ productChangesStack ;
4449 $ this ->salesChannelProvider = $ salesChannelProvider ;
4550 $ this ->productRepository = $ productRepository ;
51+ $ this ->trackedPriceTypes = $ trackedPriceTypes ;
4652 }
4753
4854 /**
4955 * @param OnFlushEventArgs $args
5056 */
5157 public function onFlush (OnFlushEventArgs $ args )
5258 {
59+ if (empty ($ this ->trackedPriceTypes )) {
60+ return ;
61+ }
62+
5363 if (false === $ this ->salesChannelProvider ->hasTrackedSalesChannels (false )) {
5464 return ;
5565 }
@@ -78,9 +88,14 @@ protected function loadRemovedAndCreatedEntities(UnitOfWork $unitOfWork): void
7888 $ salesChannelInfoArray = $ this ->salesChannelProvider ->getSalesChannelsInfoArray ();
7989 $ currenciesWSChInfos = $ this ->salesChannelProvider ->getTrackedSalesChannelCurrenciesWithSalesChannelInfos ();
8090 foreach ($ entities as $ entity ) {
81- if (($ entity instanceof ProductChannelPrice || $ entity instanceof ProductPrice) &&
82- $ entity ->getProduct ()->getId () === null ) {
83- continue ;
91+ if ($ entity instanceof ProductChannelPrice || $ entity instanceof ProductPrice) {
92+ if ($ entity ->getProduct ()->getId () === null ) {
93+ continue ;
94+ }
95+
96+ if (!\in_array ($ entity ->getType ()->getName (), $ this ->trackedPriceTypes , true )) {
97+ continue ;
98+ }
8499 }
85100
86101 if ($ entity instanceof ProductChannelPrice) {
@@ -112,6 +127,12 @@ protected function loadUpdatedEntities(UnitOfWork $unitOfWork): void
112127 $ salesChannelInfoArray = $ this ->salesChannelProvider ->getSalesChannelsInfoArray ();
113128 $ currenciesWSChInfos = $ this ->salesChannelProvider ->getTrackedSalesChannelCurrenciesWithSalesChannelInfos ();
114129 foreach ($ entities as $ entity ) {
130+ if ($ entity instanceof ProductChannelPrice || $ entity instanceof ProductPrice) {
131+ if (!\in_array ($ entity ->getType ()->getName (), $ this ->trackedPriceTypes , true )) {
132+ continue ;
133+ }
134+ }
135+
115136 if ($ entity instanceof ProductChannelPrice) {
116137 $ entityChangeSet = $ unitOfWork ->getEntityChangeSet ($ entity );
117138 if (\array_key_exists (self ::PRICE_CHANNEL_FIELD_NAME , $ entityChangeSet )) {
0 commit comments