Skip to content

Commit

Permalink
MM-25: Add logic for product prices and inventory synchronization (#50)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
alexandr-parkhomenko authored Jun 14, 2020
1 parent 3929205 commit d719683
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setAclHelper(AclHelper $aclHelper)
*
* @param ProductInterface $product
* @param SalesChannelGroup $group
* @return BalancedInventoryLevel
* @return null|BalancedInventoryLevel
*/
public function findExistingBalancedInventory(ProductInterface $product, SalesChannelGroup $group)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* )
* @ORM\Table(name="marello_assembled_ch_pr_list")
*/
class AssembledChannelPriceList extends ExtendAssembledChannelPriceList
class AssembledChannelPriceList extends ExtendAssembledChannelPriceList implements PriceListInterface
{
use EntityCreatedUpdatedAtTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* )
* @ORM\Table(name="marello_assembled_price_list")
*/
class AssembledPriceList extends ExtendAssembledPriceList
class AssembledPriceList extends ExtendAssembledPriceList implements PriceListInterface
{
use EntityCreatedUpdatedAtTrait;

Expand Down
28 changes: 28 additions & 0 deletions src/Marello/Bundle/PricingBundle/Entity/PriceListInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Marello\Bundle\PricingBundle\Entity;

use Marello\Bundle\ProductBundle\Entity\Product;

interface PriceListInterface
{
/**
* @return BasePrice
*/
public function getDefaultPrice();

/**
* @return BasePrice
*/
public function getSpecialPrice();

/**
* @return Product
*/
public function getProduct();

/**
* @return string
*/
public function getCurrency();
}
8 changes: 4 additions & 4 deletions src/Marello/Bundle/ProductBundle/Entity/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Marello\Bundle\InventoryBundle\Model\InventoryItemAwareInterface;
use Marello\Bundle\PricingBundle\Entity\AssembledChannelPriceList;
use Marello\Bundle\PricingBundle\Entity\AssembledPriceList;
use Marello\Bundle\PricingBundle\Entity\ProductChannelPrice;
use Marello\Bundle\PricingBundle\Entity\PriceListInterface;
use Marello\Bundle\PricingBundle\Model\PricingAwareInterface;
use Marello\Bundle\ProductBundle\Model\ExtendProduct;
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
Expand Down Expand Up @@ -1245,14 +1245,14 @@ public function getSalesChannelTaxCode(SalesChannel $salesChannel)

/**
* @param SalesChannel $salesChannel
* @return AssembledChannelPriceList|null
* @return PriceListInterface|null
*/
public function getSalesChannelPrice(SalesChannel $salesChannel)
{
/** @var ProductChannelPrice $productChannelPrice */
/** @var AssembledChannelPriceList $productChannelPrice */
$productChannelPrice = $this->getChannelPrices()
->filter(function ($productChannelPrice) use ($salesChannel) {
/** @var ProductChannelPrice $productChannelPrice */
/** @var AssembledChannelPriceList $productChannelPrice */
return $productChannelPrice->getChannel() === $salesChannel;
})
->first();
Expand Down
5 changes: 5 additions & 0 deletions src/Marello/Bundle/SalesBundle/Form/Type/SalesChannelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Marello\Bundle\PricingBundle\Form\EventListener\CurrencySubscriber;
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
use Oro\Bundle\CurrencyBundle\Form\Type\CurrencyType;
use Oro\Bundle\FormBundle\Utils\FormUtils;
use Oro\Bundle\LocaleBundle\Form\Type\LocalizationSelectType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
Expand Down Expand Up @@ -69,6 +70,10 @@ public function preSetDataListener(FormEvent $event)
'label' => 'marello.sales.saleschannel.create_own_group.label'
]);
}

if ($channel->getId()) {
FormUtils::replaceField($form, 'code', ['disabled' => true]);
}
}

/**
Expand Down

0 comments on commit d719683

Please sign in to comment.