Skip to content

Commit

Permalink
Export orders and carts only for already exported customers (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 20, 2022
1 parent 1dc98aa commit cbc1671
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Doctrine/ORM/ActiveCampaignOrderRepositoryTrait.php
Expand Up @@ -17,9 +17,11 @@ public function findNewCartsNotModifiedSince(DateTimeInterface $terminalDate): a
assert($this instanceof EntityRepository);

return $this->createQueryBuilder('o')
->join('o.customer', 'c')
->andWhere('o.state = :state')
->andWhere('o.customer IS NOT NULL')
->andWhere('o.activeCampaignId IS NULL')
->andWhere('c.activeCampaignId IS NOT NULL')
->andWhere('o.updatedAt < :terminalDate')
->setParameter('state', BaseOrderInterface::STATE_CART)
->setParameter('terminalDate', $terminalDate)
Expand All @@ -44,7 +46,9 @@ public function findAllToEnqueue(): array
assert($this instanceof EntityRepository);

return $this->createQueryBuilder('o')
->join('o.customer', 'c')
->where('o.customer IS NOT NULL')
->andWhere('c.activeCampaignId IS NOT NULL')
->getQuery()
->getResult()
;
Expand Down
Expand Up @@ -3,11 +3,19 @@ App\Entity\Customer\Customer:
email: 'jim@email.com'
first_name: 'James'
last_name: 'Rodriguez'
activeCampaignId: 4
customer_bob:
email: 'bob@email.com'
first_name: 'Bob'
last_name: 'Marquez'
activeCampaignId: 5
customer_sam:
email: 'sam@email.com'
first_name: 'Samuel'
last_name: 'Storm'
activeCampaignId: 6
customer_clark:
email: 'clark@email.com'
first_name: 'Clark'
last_name: 'Kent'
activeCampaignId: null
Expand Up @@ -23,4 +23,12 @@ App\Entity\Order\Order:
customer: '@customer_sam'
updatedAt: '<(new DateTime("now"))>'
activeCampaignId: null
cart_new_for_not_exported_customer:
channel: '@fashion_shop'
state: 'cart'
currency_code: 'EUR'
locale_code: 'en_US'
customer: '@customer_clark'
updatedAt: '<(new DateTime("now"))>'
activeCampaignId: null

Expand Up @@ -3,3 +3,8 @@ App\Entity\Customer\Customer:
email: 'jim@email.com'
first_name: 'James'
last_name: 'Rodriguez'
activeCampaignId: 178
customer_02:
email: 'sam@email.com'
first_name: 'Samuel'
last_name: 'Pitt'
Expand Up @@ -20,4 +20,9 @@ App\Entity\Order\Order:
customer: '@customer_01'
activeCampaignId: 6
state: 'cancelled'

order_4:
channel: '@fashion_shop'
number: '0004'
currency_code: 'EUR'
locale_code: 'en_US'
customer: '@customer_02'

0 comments on commit cbc1671

Please sign in to comment.