-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-42: Test and fix functionality (#66)
- Added functionality that catches shifting of items between pages - Moved styles to SCSS file - Removed unneeded todos - Implemented functionality to schedule sync on changing integration - Implemented functionality to remove non-existed records - Removed unneeded logic
- Loading branch information
1 parent
c9525af
commit 0530503
Showing
36 changed files
with
963 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/Marello/Bundle/Magento2Bundle/Entity/Repository/NotInOriginIdsInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\Magento2Bundle\Entity\Repository; | ||
|
||
use Doctrine\Persistence\ObjectRepository; | ||
|
||
interface NotInOriginIdsInterface extends ObjectRepository | ||
{ | ||
/** | ||
* @param array $existedRecordsOriginIds | ||
* @param int $integrationId | ||
* @return object[] | ||
*/ | ||
public function getEntitiesNotInOriginIdsInGivenIntegration( | ||
array $existedRecordsOriginIds, | ||
int $integrationId | ||
): array; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Marello/Bundle/Magento2Bundle/Entity/Repository/ProductTaxClassRepository.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\Magento2Bundle\Entity\Repository; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
|
||
class ProductTaxClassRepository extends EntityRepository implements NotInOriginIdsInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getEntitiesNotInOriginIdsInGivenIntegration( | ||
array $existedRecordsOriginIds, | ||
int $integrationId | ||
): array { | ||
$qb = $this->createQueryBuilder('m2pt'); | ||
$qb | ||
->select('m2pt') | ||
->where($qb->expr()->notIn('m2pt.originId', ':existedRecordsOriginIds')) | ||
->andWhere($qb->expr()->eq('m2pt.channel', ':integrationId')) | ||
->setParameter('existedRecordsOriginIds', $existedRecordsOriginIds) | ||
->setParameter('integrationId', $integrationId); | ||
|
||
return $qb->getQuery()->getResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Marello/Bundle/Magento2Bundle/EventListener/Doctrine/Magento2TransportListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\Magento2Bundle\EventListener\Doctrine; | ||
|
||
use Doctrine\ORM\Event\LifecycleEventArgs; | ||
use Marello\Bundle\Magento2Bundle\Entity\Magento2Transport; | ||
use Oro\Bundle\IntegrationBundle\Manager\GenuineSyncScheduler; | ||
|
||
class Magento2TransportListener | ||
{ | ||
/** @var GenuineSyncScheduler */ | ||
protected $genuineSyncScheduler; | ||
|
||
/** @var array */ | ||
protected $trackedTransportPropertyNames = []; | ||
|
||
/** @var array */ | ||
protected $integrationIdsOnSync = []; | ||
|
||
/** | ||
* @param GenuineSyncScheduler $genuineSyncScheduler | ||
* @param array $trackedTransportPropertyNames | ||
*/ | ||
public function __construct( | ||
GenuineSyncScheduler $genuineSyncScheduler, | ||
array $trackedTransportPropertyNames | ||
) { | ||
$this->genuineSyncScheduler = $genuineSyncScheduler; | ||
$this->trackedTransportPropertyNames = $trackedTransportPropertyNames; | ||
} | ||
|
||
/** | ||
* @param Magento2Transport $transport | ||
* @param LifecycleEventArgs $args | ||
*/ | ||
public function postUpdate(Magento2Transport $transport, LifecycleEventArgs $args) | ||
{ | ||
if (false === $transport->getChannel()->isEnabled()) { | ||
return; | ||
} | ||
|
||
$changeSet = $args->getEntityManager()->getUnitOfWork()->getEntityChangeSet($transport); | ||
$isTrackablePropertiesyChanged = [] !== \array_intersect( | ||
$this->trackedTransportPropertyNames, | ||
\array_keys($changeSet) | ||
); | ||
|
||
if (!$isTrackablePropertiesyChanged) { | ||
return; | ||
} | ||
|
||
$this->integrationIdsOnSync[$transport->getChannel()->getId()] = $transport->getChannel()->getId(); | ||
} | ||
|
||
public function postFlush() | ||
{ | ||
foreach ($this->integrationIdsOnSync as $integrationId) { | ||
$this->genuineSyncScheduler->schedule($integrationId); | ||
} | ||
|
||
$this->integrationIdsOnSync = []; | ||
} | ||
|
||
public function onClear() | ||
{ | ||
$this->integrationIdsOnSync = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.