Skip to content

Commit

Permalink
OroAkeneo Compatibility 5.1: add several bug fixes due compatibility … (
Browse files Browse the repository at this point in the history
#85)

* OroAkeneo Compatibility 5.1: add several bug fixes due compatibility issue with OroCommerce 5.1. Add also a small enhancement for support of OroCommerce Community version

* PHPCS FIx
  • Loading branch information
sylvainraye authored May 17, 2023
1 parent a8be204 commit 75cd839
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Async/SyncIntegrationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Oro\Bundle\AkeneoBundle\Integration\AkeneoChannel;
use Oro\Bundle\IntegrationBundle\Async\Topics;
use Oro\Bundle\IntegrationBundle\Async\Topic\SyncIntegrationTopic;
use Oro\Bundle\IntegrationBundle\Authentication\Token\IntegrationTokenAwareTrait;
use Oro\Bundle\IntegrationBundle\Entity\Channel as Integration;
use Oro\Bundle\IntegrationBundle\Provider\LoggerStrategyAwareInterface;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function __construct(

public static function getSubscribedTopics()
{
return [Topics::SYNC_INTEGRATION];
return [SyncIntegrationTopic::getName()];
}

public function process(MessageInterface $message, SessionInterface $session)
Expand Down
4 changes: 2 additions & 2 deletions Config/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public function hasChanges(): bool
$className = $configId->getClassName();
if ($configId instanceof FieldConfigId) {
$fieldName = $configId->getFieldName();
$model = $this->modelManager->getFieldModel($className, $fieldName);
$model = $this->getModelManager()->getFieldModel($className, $fieldName);
} else {
$model = $this->modelManager->getEntityModel($className);
$model = $this->getModelManager()->getEntityModel($className);
}
$diffData = $this->getDiff($config->getValues(), $model->toArray($scope));
if (!empty($diffData)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
/**
* Postpone segments updates
*/
class ProductCollectionVariantReindexMessageSendListenerDecorator extends BaseListener implements
AdditionalOptionalListenerInterface
class ProductCollectionVariantReindexMessageSendListenerDecorator extends BaseListener implements AdditionalOptionalListenerInterface
{
use AdditionalOptionalListenerTrait;

Expand Down
30 changes: 18 additions & 12 deletions ImportExport/DataConverter/ProductPriceDataConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

use Oro\Bundle\AkeneoBundle\ImportExport\AkeneoIntegrationTrait;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\PricingBundle\Entity\PriceList;
use Oro\Bundle\PricingBundle\ImportExport\DataConverter\ProductPriceDataConverter as BaseProductPriceDataConverter;
use Oro\Bundle\PricingBundle\Provider\PriceListProvider;

class ProductPriceDataConverter extends BaseProductPriceDataConverter
{
use AkeneoIntegrationTrait;

/**
* @var PriceListProvider
*/
protected $priceListProvider;

/** @var DoctrineHelper */
protected $doctrineHelper;

Expand Down Expand Up @@ -44,17 +39,12 @@ private function getPriceListId()
$transport = $this->getTransport();

if (!$transport->getPriceList()) {
return $this->priceListProvider->getDefaultPriceListId();
return $this->getDefaultPriceListId();
}

return $transport->getPriceList()->getId();
}

public function setPriceListProvider(PriceListProvider $priceListProvider): void
{
$this->priceListProvider = $priceListProvider;
}

/**
* {@inheritdoc}
*/
Expand All @@ -67,4 +57,20 @@ protected function getHeaderConversionRules()
'price_list_id' => 'priceList:id',
];
}

/**
* @return PriceList
*/
public function getDefaultPriceList()
{
return $this->doctrineHelper
->getEntityManagerForClass(PriceList::class)
->getRepository(PriceList::class)
->findOneBy(['default' => true]);
}

public function getDefaultPriceListId(): int
{
return $this->getDefaultPriceList()->getId();
}
}
3 changes: 1 addition & 2 deletions ImportExport/Processor/AttributeFamilyImportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Oro\Bundle\CacheBundle\Provider\MemoryCacheProviderAwareTrait;
use Oro\Bundle\IntegrationBundle\ImportExport\Processor\StepExecutionAwareImportProcessor;

class AttributeFamilyImportProcessor extends StepExecutionAwareImportProcessor implements
MemoryCacheProviderAwareInterface
class AttributeFamilyImportProcessor extends StepExecutionAwareImportProcessor implements MemoryCacheProviderAwareInterface
{
use MemoryCacheProviderAwareTrait;

Expand Down
3 changes: 2 additions & 1 deletion ImportExport/Processor/ProductImageImportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Oro\Bundle\AkeneoBundle\ImportExport\Processor;

use Oro\Bundle\AttachmentBundle\Entity\File;
use Oro\Bundle\BatchBundle\Item\Support\ClosableInterface;
use Oro\Bundle\IntegrationBundle\ImportExport\Processor\StepExecutionAwareImportProcessor;
use Oro\Bundle\ProductBundle\Entity\Product;
Expand Down Expand Up @@ -83,7 +84,7 @@ private function mergeImages(Product $product, array $images): Product
}

if (!is_a($image->getImage()->getParentEntityClass(), ProductImage::class, true)) {
$image->setImage(null);
$image->setImage(new File());

$product->removeImage($image);

Expand Down
7 changes: 5 additions & 2 deletions ImportExport/Writer/AttributeWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ protected function setAttributeData(FieldConfigModel $fieldConfigModel)
$attributeConfig->set('visible', false);
$attributeConfig->set('enabled', false);

$attributeConfig->set('is_global', false);
$attributeConfig->set('organization_id', $this->getOrganizationId());
// Differentiate OroCommerce EE from CE
if (class_exists('\Oro\Bundle\EntityConfigProBundle\Attribute\AttributeConfigurationProvider')) {
$attributeConfig->set('is_global', false);
$attributeConfig->set('organization_id', $this->getOrganizationId());
}
}

$attributeConfig->set('field_name', $fieldName);
Expand Down
2 changes: 1 addition & 1 deletion Layout/DataProvider/FileApplicationsDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Oro\Bundle\AttachmentBundle\Layout\DataProvider\FileApplicationsDataProvider as BaseFileApplicationsDataProvider;
use Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider;

class FileApplicationsDataProvider extends BaseFileApplicationsDataProvider
class FileApplicationsDataProvider
{
/** @var BaseFileApplicationsDataProvider */
private $applicationsDataProvider;
Expand Down
6 changes: 4 additions & 2 deletions Provider/SerializedFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class SerializedFieldProvider extends BaseSerializedFieldProvider
/** @var ConfigProvider */
private $configProvider;

public function __construct(BaseSerializedFieldProvider $serializedFieldProvider, ConfigProvider $configProvider)
{
public function __construct(
BaseSerializedFieldProvider $serializedFieldProvider,
ConfigProvider $configProvider
) {
$this->serializedFieldProvider = $serializedFieldProvider;
$this->configProvider = $configProvider;
}
Expand Down
1 change: 0 additions & 1 deletion Resources/config/importexport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ services:
parent: oro_pricing.importexport.data_converter.product_price
class: 'Oro\Bundle\AkeneoBundle\ImportExport\DataConverter\ProductPriceDataConverter'
calls:
- [ setPriceListProvider, [ '@oro_pricing.provider.price_list_provider' ] ]
- [ setDoctrineHelper, [ '@oro_entity.doctrine_helper' ] ]

# Import processor Price
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ services:
decorates: oro_attachment.layout.data_provider.file_applications
arguments:
- '@oro_akeneo.layout.data_provider.file_applications.inner'
- '@oro_entity_config.provider.attribute'
- '@oro_entity_config.provider.attachment'

oro_akeneo.layout.block_type.attribute_group:
class: 'Oro\Bundle\AkeneoBundle\Layout\Block\Type\AttributeGroupType'
Expand Down

0 comments on commit 75cd839

Please sign in to comment.