Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
1f507047
Commit
1f507047
authored
Jun 11, 2020
by
attilak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Outsource filter notifications to resource model
parent
2dfd893e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
Model/Cron.php
Model/Cron.php
+1
-15
Model/ResourceModel/Notification/Collection.php
Model/ResourceModel/Notification/Collection.php
+26
-0
No files found.
Model/Cron.php
View file @
1f507047
...
...
@@ -341,22 +341,8 @@ class Cron
$this
->
_order
=
null
;
// execute notifications from 2 minute or earlier because order could not yet been created by magento
$dateStart
=
new
\DateTime
();
$dateStart
->
modify
(
'-5 day'
);
$dateEnd
=
new
\DateTime
();
$dateEnd
->
modify
(
'-1 minute'
);
$dateRange
=
[
'from'
=>
$dateStart
,
'to'
=>
$dateEnd
,
'datetime'
=>
true
];
// create collection
$notifications
=
$this
->
_notificationFactory
->
create
();
$notifications
->
addFieldToFilter
(
'done'
,
0
);
$notifications
->
addFieldToFilter
(
'processing'
,
0
);
$notifications
->
addFieldToFilter
(
'created_at'
,
$dateRange
);
$notifications
->
addFieldToFilter
(
'error_count'
,
[
'lt'
=>
Notification
::
MAX_ERROR_COUNT
]);
// Process the notifications in ascending order by creation date and event_code
$notifications
->
getSelect
()
->
order
(
'created_at ASC'
)
->
order
(
'event_code ASC'
);
$notifications
->
notificationsToProcessFilter
();
// OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed
$offerClosedMinDate
=
new
\DateTime
();
...
...
Model/ResourceModel/Notification/Collection.php
View file @
1f507047
...
...
@@ -46,4 +46,30 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
$this
->
addFieldToFilter
(
'created_at'
,
$dateRange
);
return
$this
;
}
/**
* Filter the notifications table to get non processed or done notifications without 5 or more errors older than
* 2 minutes but not older than 5 days, ordered by created_at and event_code columns
*
* @return $this
*/
public
function
notificationsToProcessFilter
()
{
// execute notifications from 2 minute or earlier because order could not yet been created by magento
$dateStart
=
new
\DateTime
();
$dateStart
->
modify
(
'-5 day'
);
$dateEnd
=
new
\DateTime
();
$dateEnd
->
modify
(
'-1 minute'
);
$dateRange
=
[
'from'
=>
$dateStart
,
'to'
=>
$dateEnd
,
'datetime'
=>
true
];
$this
->
addFieldToFilter
(
'done'
,
0
);
$this
->
addFieldToFilter
(
'processing'
,
0
);
$this
->
addFieldToFilter
(
'created_at'
,
$dateRange
);
$this
->
addFieldToFilter
(
'error_count'
,
[
'lt'
=>
\Adyen\Payment\Model\Notification
::
MAX_ERROR_COUNT
]);
// Process the notifications in ascending order by creation date and event_code
$this
->
getSelect
()
->
order
(
'created_at ASC'
)
->
order
(
'event_code ASC'
);
return
$this
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment