Skip to content

Commit 1d6be06

Browse files
alexandr-parkhomenko24198
authored andcommitted
MM-35: Fix issue 'Removed special product price won't sync on Magento side' (#58)
1 parent d0d640d commit 1d6be06

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

src/Marello/Bundle/PricingBundle/Form/EventListener/ChannelPricingSubscriber.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,19 @@ public function postSubmit(FormEvent $event)
146146
$assembledChannelPriceList->getDefaultPrice()
147147
->setType($this->getPriceType(PriceTypeInterface::DEFAULT_PRICE))
148148
->setCurrency($assembledChannelPriceList->getCurrency());
149-
if ($assembledChannelPriceList->getSpecialPrice() !== null &&
150-
$assembledChannelPriceList->getSpecialPrice()->getValue() === null) {
151-
$assembledChannelPriceList->setSpecialPrice(null);
152-
} elseif ($assembledChannelPriceList->getSpecialPrice() !== null) {
149+
150+
/** Restores currency in case if product price exists */
151+
if ($assembledChannelPriceList->getSpecialPrice() !== null) {
153152
$assembledChannelPriceList->getSpecialPrice()
154153
->setType($this->getPriceType(PriceTypeInterface::SPECIAL_PRICE))
155154
->setCurrency($assembledChannelPriceList->getCurrency());
156155
}
156+
157+
/** Removes product price from price list in case if user clear its value */
158+
if ($assembledChannelPriceList->getSpecialPrice() !== null &&
159+
$assembledChannelPriceList->getSpecialPrice()->getValue() === null) {
160+
$assembledChannelPriceList->setSpecialPrice(null);
161+
}
157162
}
158163

159164
if ($form->has('removeSalesChannels') && !empty($form->get('removeSalesChannels')->getData())) {
@@ -190,7 +195,9 @@ public function postSubmit(FormEvent $event)
190195
protected function getPricingEnabled(FormInterface $form)
191196
{
192197
if (!$form->has(PricingAwareInterface::CHANNEL_PRICING_STATE_KEY)) {
193-
throw new \InvalidArgumentException(sprintf('%s form child is missing'));
198+
throw new \InvalidArgumentException(
199+
sprintf('%s form child is missing', PricingAwareInterface::CHANNEL_PRICING_STATE_KEY)
200+
);
194201
}
195202

196203
$data = $form->get(PricingAwareInterface::CHANNEL_PRICING_STATE_KEY)->getData();

src/Marello/Bundle/PricingBundle/Form/EventListener/PricingSubscriber.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,31 @@ public function postSubmit(FormEvent $event)
116116
$assembledPriceList->getDefaultPrice()
117117
->setType($this->getPriceType(PriceTypeInterface::DEFAULT_PRICE))
118118
->setCurrency($assembledPriceList->getCurrency());
119+
120+
/** Restores currency in case if product price exists */
121+
if ($assembledPriceList->getSpecialPrice() !== null) {
122+
$assembledPriceList->getSpecialPrice()
123+
->setType($this->getPriceType(PriceTypeInterface::SPECIAL_PRICE))
124+
->setCurrency($assembledPriceList->getCurrency());
125+
}
126+
127+
/** Removes product price from price list in case if user clear its value */
119128
if ($assembledPriceList->getSpecialPrice() !== null &&
120129
$assembledPriceList->getSpecialPrice()->getValue() === null) {
121130
$assembledPriceList->setSpecialPrice(null);
122-
} elseif ($assembledPriceList->getSpecialPrice() !== null) {
123-
$assembledPriceList->getSpecialPrice()
124-
->setType($this->getPriceType(PriceTypeInterface::SPECIAL_PRICE))
131+
}
132+
133+
/** Restores currency in case if product price exists */
134+
if ($assembledPriceList->getMsrpPrice() !== null) {
135+
$assembledPriceList->getMsrpPrice()
136+
->setType($this->getPriceType(PriceTypeInterface::MSRP_PRICE))
125137
->setCurrency($assembledPriceList->getCurrency());
126138
}
139+
140+
/** Removes product price from price list in case if user clear its value */
127141
if ($assembledPriceList->getMsrpPrice() !== null &&
128142
$assembledPriceList->getMsrpPrice()->getValue() === null) {
129143
$assembledPriceList->setMsrpPrice(null);
130-
} elseif ($assembledPriceList->getMsrpPrice() !== null) {
131-
$assembledPriceList->getMsrpPrice()
132-
->setType($this->getPriceType(PriceTypeInterface::MSRP_PRICE))
133-
->setCurrency($assembledPriceList->getCurrency());
134144
}
135145
}
136146

0 commit comments

Comments
 (0)