Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export orders and carts only for already exported customers #49

Merged
merged 1 commit into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'