Skip to content

Commit a0b0778

Browse files
MM-25: Add logic for product prices and inventory synchronization (#50)
- Disabled field 'code' on editing for existing SalesChannel, to prevent issues with an incorrect mapping between salesChannel and website - Fixed issue with price sync - Fixed issue with remove remote data on integration deactivation - Fixed issue with updating SKU - Fixed issue with updating price when using default price
1 parent e3d1dbe commit a0b0778

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

src/Marello/Bundle/InventoryBundle/Entity/Repository/BalancedInventoryRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setAclHelper(AclHelper $aclHelper)
3030
*
3131
* @param ProductInterface $product
3232
* @param SalesChannelGroup $group
33-
* @return BalancedInventoryLevel
33+
* @return null|BalancedInventoryLevel
3434
*/
3535
public function findExistingBalancedInventory(ProductInterface $product, SalesChannelGroup $group)
3636
{

src/Marello/Bundle/PricingBundle/Entity/AssembledChannelPriceList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* )
2525
* @ORM\Table(name="marello_assembled_ch_pr_list")
2626
*/
27-
class AssembledChannelPriceList extends ExtendAssembledChannelPriceList
27+
class AssembledChannelPriceList extends ExtendAssembledChannelPriceList implements PriceListInterface
2828
{
2929
use EntityCreatedUpdatedAtTrait;
3030

src/Marello/Bundle/PricingBundle/Entity/AssembledPriceList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* )
2424
* @ORM\Table(name="marello_assembled_price_list")
2525
*/
26-
class AssembledPriceList extends ExtendAssembledPriceList
26+
class AssembledPriceList extends ExtendAssembledPriceList implements PriceListInterface
2727
{
2828
use EntityCreatedUpdatedAtTrait;
2929

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Marello\Bundle\PricingBundle\Entity;
4+
5+
use Marello\Bundle\ProductBundle\Entity\Product;
6+
7+
interface PriceListInterface
8+
{
9+
/**
10+
* @return BasePrice
11+
*/
12+
public function getDefaultPrice();
13+
14+
/**
15+
* @return BasePrice
16+
*/
17+
public function getSpecialPrice();
18+
19+
/**
20+
* @return Product
21+
*/
22+
public function getProduct();
23+
24+
/**
25+
* @return string
26+
*/
27+
public function getCurrency();
28+
}

src/Marello/Bundle/ProductBundle/Entity/Product.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Marello\Bundle\InventoryBundle\Model\InventoryItemAwareInterface;
1111
use Marello\Bundle\PricingBundle\Entity\AssembledChannelPriceList;
1212
use Marello\Bundle\PricingBundle\Entity\AssembledPriceList;
13-
use Marello\Bundle\PricingBundle\Entity\ProductChannelPrice;
13+
use Marello\Bundle\PricingBundle\Entity\PriceListInterface;
1414
use Marello\Bundle\PricingBundle\Model\PricingAwareInterface;
1515
use Marello\Bundle\ProductBundle\Model\ExtendProduct;
1616
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
@@ -1245,14 +1245,14 @@ public function getSalesChannelTaxCode(SalesChannel $salesChannel)
12451245

12461246
/**
12471247
* @param SalesChannel $salesChannel
1248-
* @return AssembledChannelPriceList|null
1248+
* @return PriceListInterface|null
12491249
*/
12501250
public function getSalesChannelPrice(SalesChannel $salesChannel)
12511251
{
1252-
/** @var ProductChannelPrice $productChannelPrice */
1252+
/** @var AssembledChannelPriceList $productChannelPrice */
12531253
$productChannelPrice = $this->getChannelPrices()
12541254
->filter(function ($productChannelPrice) use ($salesChannel) {
1255-
/** @var ProductChannelPrice $productChannelPrice */
1255+
/** @var AssembledChannelPriceList $productChannelPrice */
12561256
return $productChannelPrice->getChannel() === $salesChannel;
12571257
})
12581258
->first();

src/Marello/Bundle/SalesBundle/Form/Type/SalesChannelType.php

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Marello\Bundle\PricingBundle\Form\EventListener\CurrencySubscriber;
66
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
77
use Oro\Bundle\CurrencyBundle\Form\Type\CurrencyType;
8+
use Oro\Bundle\FormBundle\Utils\FormUtils;
89
use Oro\Bundle\LocaleBundle\Form\Type\LocalizationSelectType;
910
use Symfony\Component\Form\AbstractType;
1011
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -69,6 +70,10 @@ public function preSetDataListener(FormEvent $event)
6970
'label' => 'marello.sales.saleschannel.create_own_group.label'
7071
]);
7172
}
73+
74+
if ($channel->getId()) {
75+
FormUtils::replaceField($form, 'code', ['disabled' => true]);
76+
}
7277
}
7378

7479
/**

0 commit comments

Comments
 (0)