Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: oroinc/OroAkeneoBundle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.2.1
Choose a base ref
...
head repository: oroinc/OroAkeneoBundle
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.1
Choose a head ref

Commits on Apr 27, 2021

  1. Copy the full SHA
    e7b1c9b View commit details
  2. Copy the full SHA
    32622ed View commit details
  3. Copy the full SHA
    71af3ea View commit details

Commits on Apr 30, 2021

  1. Copy the full SHA
    ab1b71f View commit details

Commits on May 21, 2021

  1. AKM-23: Fix MFA conflict

    dxops committed May 21, 2021
    Copy the full SHA
    e8422c2 View commit details
  2. Fix cs

    dxops committed May 21, 2021
    Copy the full SHA
    a90e0a1 View commit details

Commits on Jun 3, 2021

  1. Drop legacy stuff

    dxops committed Jun 3, 2021
    Copy the full SHA
    aa53f15 View commit details
  2. Drop old PHP

    dxops committed Jun 3, 2021
    Copy the full SHA
    3fff71a View commit details
  3. Revert aa53f15

    dxops committed Jun 3, 2021
    Copy the full SHA
    8981987 View commit details

Commits on Jun 25, 2021

  1. Render ManyToMany localizable Akeneo attributes on PDP

    - migrate to new config scope
    dxops committed Jun 25, 2021
    Copy the full SHA
    0615411 View commit details

Commits on Jul 8, 2021

  1. Copy the full SHA
    76eaa19 View commit details
  2. Copy the full SHA
    0bf54f5 View commit details

Commits on Jul 13, 2021

  1. Copy the full SHA
    fa683f0 View commit details
  2. Copy the full SHA
    ac27f8c View commit details

Commits on Aug 10, 2021

  1. Copy the full SHA
    bd1cf43 View commit details

Commits on Aug 31, 2021

  1. AKM-29: Memory leak in api step

    - flush removed from the core causes \Oro\Bundle\MessageQueueBundle\Client\BufferedMessageProducer::flushBuffer skip
    - causes \Oro\Bundle\AkeneoBundle\ImportExport\Writer\AsyncWriter to keep messages and json data in memory
    - \Akeneo\Pim\ApiClient\Pagination\Page::getPage do not free up memory because of json data in use
    dxops committed Aug 31, 2021
    Copy the full SHA
    aa03a9c View commit details

Commits on Dec 7, 2021

  1. Update FileApplicationsDataProvider.php (#61)

    Avoid type error in some weard cases.
    mrfroasty authored and dxops committed Dec 7, 2021
    Copy the full SHA
    abe1e25 View commit details
  2. Update FileApplicationsDataProvider.php (#61)

    Avoid type error in some weard cases.
    dxops committed Dec 7, 2021
    Copy the full SHA
    ad78ab8 View commit details

Commits on Mar 6, 2022

  1. Copy the full SHA
    b582797 View commit details

Commits on Apr 13, 2022

  1. AKM-34: Product filter breaks configurable products (#67)

    * AKM-34: Product filter breaks configurable products
    AKM-31: Split products and product models filters
    do not allow duplicate jobs
    dxops authored Apr 13, 2022
    Copy the full SHA
    d9fd09b View commit details

Commits on May 26, 2022

  1. Add cleanup to cron

    dxops committed May 26, 2022
    Copy the full SHA
    ec7a311 View commit details

Commits on Jun 3, 2022

  1. Copy the full SHA
    8aa8dde View commit details

Commits on Aug 18, 2022

  1. Clear EM when field changes exists

    - fix oom during 2nd api step run
    dxops committed Aug 18, 2022
    Copy the full SHA
    ee49296 View commit details

Commits on Aug 23, 2022

  1. Fix attributes usage for models (#76)

    Fix attributes usage for models
    Keep status from Akeneo for simple products
    Fix mapped sku usage
    dxops committed Aug 23, 2022
    Copy the full SHA
    5f34663 View commit details
Showing with 1,415 additions and 489 deletions.
  1. +20 −0 .github/workflows/php.yml
  2. +1 −0 .gitignore
  3. +13 −9 .php_cs.php
  4. +0 −15 .travis.yml
  5. +24 −17 Async/ImportProductProcessor.php
  6. +1 −16 Async/SyncIntegrationProcessor.php
  7. +104 −0 Command/CleanupCommand.php
  8. +2 −1 Controller/ValidateConnectionController.php
  9. +1 −0 DependencyInjection/OroAkeneoExtension.php
  10. +26 −0 Entity/AkeneoSettings.php
  11. +5 −0 EventListener/AdditionalOptionalListenerTrait.php
  12. +2 −0 Form/Extension/ChannelTypeExtension.php
  13. +10 −1 Form/Type/AkeneoSettingsType.php
  14. +82 −0 ImportExport/EventListener/FileStrategyEventListener.php
  15. +0 −57 ImportExport/Processor/AsyncProcessor.php
  16. +4 −2 ImportExport/Processor/AttributeImportProcessor.php
  17. +52 −16 ImportExport/Processor/ProductVariantProcessor.php
  18. +3 −4 ImportExport/Reader/ProductImageReader.php
  19. +4 −4 ImportExport/Reader/ProductPriceReader.php
  20. +4 −4 ImportExport/Reader/ProductReader.php
  21. +4 −4 ImportExport/Reader/ProductVariantReader.php
  22. +4 −6 ImportExport/Strategy/AttributeFamilyImportStrategy.php
  23. +11 −6 ImportExport/Strategy/BrandImportStrategy.php
  24. +3 −5 ImportExport/Strategy/CategoryImportStrategy.php
  25. +8 −0 ImportExport/Strategy/ExistingEntityAwareInterface.php
  26. +35 −0 ImportExport/Strategy/ImportLogStrategyHelper.php
  27. +1 −1 ImportExport/Strategy/ImportStrategyHelper.php
  28. +9 −56 ImportExport/Strategy/ProductImportStrategy.php
  29. +129 −118 ImportExport/Writer/AsyncWriter.php
  30. +14 −0 ImportExport/Writer/AttributeWriter.php
  31. +264 −0 ImportExport/Writer/ConfigurableAsyncWriter.php
  32. +4 −1 ImportExport/Writer/CumulativeWriter.php
  33. +3 −3 Integration/AkeneoSearchBuilder.php
  34. +59 −17 Integration/AkeneoTransport.php
  35. +4 −0 Integration/AkeneoTransportInterface.php
  36. +1 −1 Integration/Api/MeasurementFamilyApi.php
  37. +1 −1 Integration/Api/MeasurementFamilyApiInterface.php
  38. +1 −1 Integration/Api/ReferenceEntityApi.php
  39. +1 −1 Integration/Api/ReferenceEntityApiInterface.php
  40. +1 −1 Integration/Api/ReferenceEntityAttributeApi.php
  41. +1 −1 Integration/Api/ReferenceEntityAttributeApiInterface.php
  42. +1 −1 Integration/Api/ReferenceEntityAttributeOptionApi.php
  43. +1 −1 Integration/Api/ReferenceEntityAttributeOptionApiInterface.php
  44. +2 −2 Integration/Api/ReferenceEntityMediaFileApi.php
  45. +1 −1 Integration/Api/ReferenceEntityMediaFileApiInterface.php
  46. +1 −1 Integration/Api/ReferenceEntityRecordApi.php
  47. +1 −1 Integration/Api/ReferenceEntityRecordApiInterface.php
  48. +83 −0 Integration/Connector/ConfigurableProductConnector.php
  49. +4 −14 Integration/Connector/ProductConnector.php
  50. +45 −0 Integration/Iterator/ConfigurableProductIterator.php
  51. +2 −2 Job/Context/SimpleContextAggregator.php
  52. +126 −0 Layout/Block/Type/AttributeGroupType.php
  53. +2 −2 Layout/DataProvider/FileApplicationsDataProvider.php
  54. +2 −1 Migrations/Schema/OroAkeneoBundleInstaller.php
  55. +66 −0 Migrations/Schema/v1_15/OroAkeneoMigration.php
  56. +19 −0 Migrations/Schema/v1_16/OroAkeneoMigration.php
  57. +11 −39 README.md
  58. +15 −1 Resources/config/batch_jobs.yml
  59. +9 −0 Resources/config/commands.yml
  60. +47 −15 Resources/config/importexport.yml
  61. +19 −1 Resources/config/services.yml
  62. +5 −0 Resources/translations/messages.en.yml
  63. +2 −0 Resources/translations/validators.en.yml
  64. +11 −0 Resources/views/Form/fields.html.twig
  65. +16 −0 Tools/CacheProviderTrait.php
  66. +7 −10 Validator/UniqueProductVariantLinksValidator.php
  67. +1 −28 composer.json
20 changes: 20 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PHP Composer

on:
push:
branches: [ master 4.2 4.1 3.1 1.6 ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: php -r "copy('https://cs.symfony.com/download/php-cs-fixer-v3.phar', 'php-cs-fixer.phar');"

- name: Run php-cs-fixer
run: php php-cs-fixer.phar fix --dry-run --config=.php_cs.php --cache-file=.php_cs.cache --verbose --show-progress=dots --diff --allow-risky=yes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.phar
*.cache
.idea
22 changes: 13 additions & 9 deletions .php_cs.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = \PhpCsFixer\Finder::create()
->in(__DIR__);

return PhpCsFixer\Config::create()
return (new \PhpCsFixer\Config())
->setFinder($finder)
->setRules(
[
// generic PSRs
'@PSR1' => true,
'@PSR2' => true,
'psr0' => true,
'psr4' => true,
'@PSR12' => true,
'@PSR12:risky' => true,
'psr_autoloading' => true,

// imports
'ordered_imports' => true,
@@ -39,11 +40,13 @@
'escape_implicit_backslashes' => false,

// PHP
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,

'use_arrow_functions' => false,
'get_class_to_class_keyword' => false,
'void_return' => false,
'visibility_required' => false,
'list_syntax' => ['syntax' => 'long'],
'declare_strict_types' => false,

@@ -64,11 +67,11 @@
'@Symfony:risky' => true,
'phpdoc_types_order' => false,
'phpdoc_separation' => false,
'phpdoc_inline_tag' => false,
'visibility_required' => ['elements' => ['property', 'method']],
'types_spaces' => false,
'native_function_invocation' => false,
'concat_space' => ['spacing' => 'one'],
'single_space_after_construct' => false,
'trailing_comma_in_multiline_array' => false,
'self_accessor' => false,
'yoda_style' => false,
'phpdoc_summary' => false,
@@ -87,6 +90,7 @@
'ternary_operator_spaces' => false,
'phpdoc_no_useless_inheritdoc' => false,
'class_definition' => false,
'string_length_to_empty' => false,
]
)
->setRiskyAllowed(true);
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

41 changes: 24 additions & 17 deletions Async/ImportProductProcessor.php
Original file line number Diff line number Diff line change
@@ -3,14 +3,15 @@
namespace Oro\Bundle\AkeneoBundle\Async;

use Doctrine\ORM\EntityManagerInterface;
use Oro\Bundle\AkeneoBundle\Tools\CacheProviderTrait;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\IntegrationBundle\Authentication\Token\IntegrationTokenAwareTrait;
use Oro\Bundle\IntegrationBundle\Entity\Channel as Integration;
use Oro\Bundle\IntegrationBundle\Entity\FieldsChanges;
use Oro\Bundle\IntegrationBundle\Provider\SyncProcessorRegistry;
use Oro\Bundle\SecurityBundle\Authentication\Token\UsernamePasswordOrganizationToken;
use Oro\Bundle\MessageQueueBundle\Entity\Job;
use Oro\Component\MessageQueue\Client\TopicSubscriberInterface;
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
use Oro\Component\MessageQueue\Job\Job;
use Oro\Component\MessageQueue\Job\JobRunner;
use Oro\Component\MessageQueue\Transport\MessageInterface;
use Oro\Component\MessageQueue\Transport\SessionInterface;
@@ -20,6 +21,7 @@

class ImportProductProcessor implements MessageProcessorInterface, TopicSubscriberInterface
{
use CacheProviderTrait;
use IntegrationTokenAwareTrait;

/** @var DoctrineHelper */
@@ -91,37 +93,42 @@ public function process(MessageInterface $message, SessionInterface $session)
return self::REJECT;
}

$this->setTemporaryUserIntegrationToken($integration);
$this->setTemporaryIntegrationToken($integration);

$result = $this->jobRunner->runDelayed(
$body['jobId'],
function (JobRunner $jobRunner, Job $child) use ($integration, $body) {
$this->doctrineHelper->refreshIncludingUnitializedRelations($integration);
$processor = $this->syncProcessorRegistry->getProcessorForIntegration($integration);

$em = $this->doctrineHelper->getEntityManager(FieldsChanges::class);
/** @var FieldsChanges $fieldsChanges */
$fieldsChanges = $em
->getRepository(FieldsChanges::class)
->findOneBy(['entityId' => $child->getId(), 'entityClass' => Job::class]);

if (!$fieldsChanges) {
$this->logger->error(
sprintf('Source data from Akeneo not found for job: %s', $child->getId())
);

return false;
}

$this->cacheProvider->save('akeneo', $fieldsChanges->getChangedFields());

$status = $processor->process(
$integration,
$body['connector'] ?? null,
$body['connector_parameters'] ?? []
);

$em->clear(FieldsChanges::class);

return $status;
}
);

$this->setTemporaryIntegrationToken($integration);

return $result ? self::ACK : self::REJECT;
}

private function setTemporaryUserIntegrationToken(Integration $integration)
{
$token = new UsernamePasswordOrganizationToken(
$integration->getDefaultUserOwner(),
$integration->getDefaultUserOwner()->getUsername(),
'main',
$integration->getOrganization()
);
$token->setAttribute('owner_description', 'Integration: ' . $integration->getName());
$this->tokenStorage->setToken($token);
}
}
17 changes: 1 addition & 16 deletions Async/SyncIntegrationProcessor.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
use Oro\Bundle\IntegrationBundle\Provider\LoggerStrategyAwareInterface;
use Oro\Bundle\IntegrationBundle\Provider\SyncProcessorRegistry;
use Oro\Bundle\MessageQueueBundle\Entity\Job;
use Oro\Bundle\SecurityBundle\Authentication\Token\UsernamePasswordOrganizationToken;
use Oro\Component\MessageQueue\Client\TopicSubscriberInterface;
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
use Oro\Component\MessageQueue\Job\JobRunner;
@@ -106,7 +105,7 @@ public function process(MessageInterface $message, SessionInterface $session)

$em->getConnection()->getConfiguration()->setSQLLogger(null);

$this->setTemporaryUserIntegrationToken($integration);
$this->setTemporaryIntegrationToken($integration);
$integration->getTransport()->getSettingsBag()->set('page_size', $body['transport_batch_size']);

$result = $this->jobRunner->runUnique(
@@ -128,20 +127,6 @@ function (JobRunner $jobRunner, Job $job) use ($integration, $body) {
}
);

$this->setTemporaryIntegrationToken($integration);

return $result ? self::ACK : self::REJECT;
}

private function setTemporaryUserIntegrationToken(Integration $integration)
{
$token = new UsernamePasswordOrganizationToken(
$integration->getDefaultUserOwner(),
$integration->getDefaultUserOwner()->getUsername(),
'main',
$integration->getOrganization()
);
$token->setAttribute('owner_description', 'Integration: ' . $integration->getName());
$this->tokenStorage->setToken($token);
}
}
104 changes: 104 additions & 0 deletions Command/CleanupCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace Oro\Bundle\AkeneoBundle\Command;

use Oro\Bundle\BatchBundle\ORM\Query\BufferedIdentityQueryResultIterator;
use Oro\Bundle\CronBundle\Command\CronCommandInterface;
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper;
use Oro\Bundle\IntegrationBundle\Entity\FieldsChanges;
use Oro\Bundle\MessageQueueBundle\Entity\Job;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Clears old records from oro_integration_fields_changes table before repack.
*/
class CleanupCommand extends Command implements CronCommandInterface
{
/** @var string */
protected static $defaultName = 'oro:cron:akeneo:cleanup';

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

public function __construct(DoctrineHelper $doctrineHelper)
{
$this->doctrineHelper = $doctrineHelper;
parent::__construct();
}

public function isActive()
{
return true;
}

public function getDefaultDefinition()
{
return '0 2 * * 6';
}

public function configure()
{
$this
->setDescription('Clears old records from oro_integration_fields_changes table.')
->setHelp(
<<<'HELP'
The <info>%command.name%</info> command clears fields changes for complete job records
from <comment>oro_integration_fields_changes</comment> table.
<info>php %command.full_name%</info>
HELP
);
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(sprintf(
'<comment>Number of fields changes that has been deleted:</comment> %d',
$this->deleteRecords()
));

$output->writeln('<info>Fields changes cleanup complete</info>');
}

private function deleteRecords(): int
{
$qb = $this->doctrineHelper
->getEntityManagerForClass(FieldsChanges::class)
->getRepository(FieldsChanges::class)
->createQueryBuilder('fc');

$qb
->delete(FieldsChanges::class, 'fc')
->where($qb->expr()->eq('fc.entityClass', ':class'))
->setParameter('class', Job::class)
->andWhere($qb->expr()->in('fc.entityId', ':ids'));

$jqb = $this->doctrineHelper
->getEntityManagerForClass(Job::class)
->getRepository(Job::class)
->createQueryBuilder('j');

$jqb
->select('j.id')
->where($jqb->expr()->in('j.status', ':statuses'))
->setParameter('statuses', [Job::STATUS_SUCCESS, Job::STATUS_CANCELLED, Job::STATUS_FAILED, Job::STATUS_STALE])
->orderBy($jqb->expr()->desc('j.id'));

$iterator = new BufferedIdentityQueryResultIterator($jqb->getQuery());

$result = 0;
$iterator->setPageLoadedCallback(function (array $rows) use ($qb, &$result): array {
$ids = array_column($rows, 'id');

$result = $result + $qb->setParameter('ids', $ids)->getQuery()->execute();

return $ids;
});

iterator_to_array($iterator);

return $result;
}
}
3 changes: 2 additions & 1 deletion Controller/ValidateConnectionController.php
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ public function validateConnectionAction(Request $request, Channel $channel = nu
$akeneoSettings->setPassword($akeneoSettingsEntity->getPassword());
}

/** @var \Oro\Bundle\CurrencyBundle\Provider\CurrencyListProviderInterface */
$currencyConfig = $this->container->get('oro_currency.config.currency');

$akeneoChannelNames = [];
@@ -93,7 +94,7 @@ public function validateConnectionAction(Request $request, Channel $channel = nu
'akeneoLocales' => $akeneoLocales,
'success' => $success,
'message' => $this->get('translator')->trans($message),
'currencyList' => $currencyConfig->getCurrencies(),
'currencyList' => $currencyConfig->getCurrencyList(),
]
);
}
1 change: 1 addition & 0 deletions DependencyInjection/OroAkeneoExtension.php
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ class OroAkeneoExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('commands.yml');
$loader->load('integration.yml');
$loader->load('importexport.yml');
$loader->load('services.yml');
26 changes: 26 additions & 0 deletions Entity/AkeneoSettings.php
Original file line number Diff line number Diff line change
@@ -89,6 +89,12 @@ class AkeneoSettings extends Transport
* @ORM\Column(name="akeneo_product_filter", type="text", nullable=true)
*/
protected $productFilter;
/**
* @var string
*
* @ORM\Column(name="akeneo_conf_product_filter", type="text", nullable=true)
*/
protected $configurableProductFilter;
/**
* @var string
*
@@ -275,6 +281,26 @@ public function setProductFilter($productFilter)
return $this;
}

/**
* @return string
*/
public function getConfigurableProductFilter()
{
return $this->configurableProductFilter;
}

/**
* @param string $configurableProductFilter
*
* @return self
*/
public function setConfigurableProductFilter($configurableProductFilter)
{
$this->configurableProductFilter = $configurableProductFilter;

return $this;
}

/**
* @return ParameterBag
*/
Loading