Skip to content

Commit

Permalink
Merge pull request #52 from feedaty/develop
Browse files Browse the repository at this point in the history
select only the orders modified in the last hour
  • Loading branch information
altravista committed Mar 10, 2022
2 parents 37cf576 + 4e8183f commit 0354c56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Cron/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function execute()
);
}

$this->ordersHelper->setFeedatyCustomerNotified($order->getEntityId());
$i++;
}

Expand All @@ -117,7 +118,10 @@ public function execute()
foreach ($response['Data'] as $data){
//if order Success or Duplicated set Feedaty Customer Notification true
if($data['Status'] == '1' || $data['Status'] == '201'){
$this->ordersHelper->setFeedatyCustomerNotified((int)$data['OrderID']);
$this->logger->info("Feedaty | Order sent successfull: order ID " . $order->getEntityId() . ' - date: ' . date('Y-m-d H:i:s') );
}
else {
$this->logger->critical("Feedaty | Order not sent: order ID " .$order->getEntityId() . ' - date: ' . date('Y-m-d H:i:s') );
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion Helper/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@ public function getOrders()
$ordersNotified[] = 0;
}
try {
$to = date("Y-m-d h:i:s"); // current date
$range = strtotime('-1 hours', strtotime($to));
$from = date('Y-m-d h:i:s', $range); // 24 hours before

$criteria = $this->searchCriteriaBuilder
->addFilter('status',$status,'eq')
->addFilter('status', $status,'eq')
->addFilter('entity_id', $ordersNotified, 'nin')
->addFilter('updated_at', $from, 'gteq')
->setPageSize(50)
->setCurrentPage(1)
->create();

$orderResult = $this->orderRepository->getList($criteria);

$orders = $orderResult->getItems();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"AFL-3.0"
],

"version": "2.7.5-stable",
"version": "2.7.6-stable",


"type": "magento2-module",
Expand Down

0 comments on commit 0354c56

Please sign in to comment.