For more details see how the Order Archive for Magento 2 extension works.
Magento 2 Order Archive extension enables store administrators easily delete or archive any orders they need to keep orders grid clean and up-to-date.
Enable Orders Archive - Ser the option to 'yes' to activate the extension.
Hide Archived Orders on Frontend - Enable the option to remove archived orders from customer accounts.
Archive Orders Older Than- Specify the number of days before orders get archived.
Order Status to Apply to - Choose order statuses which should be archived. You can select multiple statuses at a time.
Archive Frequency - Choose one of 5 predefined options for archive frequency:
Notify after archiving is complete - Enable this option to inform your store administrator about each successful archive run.
Send to e-mail address - specify the email address to which notifications will be sent.
E-mail template - specify an email template for admin notifications. You can either choose the default one, you use your custom template.
Export Archived Orders - you can export all archived orders for further processing to CSV or XML files.
Remove from Archive - apply this action to restore archive orders. All restored orders will be displayed on the Orders Grid.
Delete Permanently - choose this action to deleted selected archive orders.
With the Order Archive for Magento 2 extension, you can manage your order archive using API. There are 3 operations you are able to perform. These are:
Let's dig into examples.
Operation: V1/amastyMoveToArchive
Description: Operation moves orders and order-related entities to archive tables amastyorderarchive%. Operation affects all the entities associated with the order: invoices, credit memos, shippings if they exist for the order.
Method: POST
Required:
orderids=(Array[integer]) example: orderids=12,1,4,5
Example:
{ "orderIds": [ 1, 4,5,12 ] } Success response code: 200 Success response: { "order_ids": [ 1, 4, 5, 12 ], "invoice_ids": [ 1 ], "creditmemo_ids": [ 4 ], "shipment_ids": [ 1, 12 ] }
Error Response: 401 code – Unauthorized, 400 – unexpected error
Operation: /V1/amastyMoveFromArchive
Description: Operation moves orders and order-related entities from archive tables “amastyorderarchive%”. Operation affect all the entities associated with the order: invoices, credit memos, shippings if they exist for the order.
Method: POST
Required:
orderids=(Array[integer]) example: orderids=12,1,4,5
Example:
{ "orderIds": [ 1, 4,5,12 ] } Success response code: 200 Success response: { "order_ids": [ 1, 4, 5, 12 ], "invoice_ids": [ 1 ], "creditmemo_ids": [ 4 ], "shipment_ids": [ 1, 12 ] }
Error Response: 401 code – Unauthorized, 400 – unexpected error
Operation: /V1/amastyRemovePermanently
Description: Completely removes orders and related data from the database without the possibility of their recovery.
Method: POST
Required: orderids=(Array[integer])
Example:
orderids=12,1,4,5 Success response code: 200 Success response: { "order_ids": [ "[\"5\"]" ], "invoice_ids": null, "creditmemo_ids": null, "shipment_ids": null }
Error Response: 401 code – Unauthorized, 400 – unexpected error
Magento 2 Order Archive extension is preintegrated with Cron Tasks List to provide store owners with an opportunity to track and manage all cron tasks running in the website background.
To view all scheduled and executed cron tasks, go to System → Cron Tasks List
Run all cron tasks and generate their schedule by clicking the ‘Run Cron’ button. Also you can delete separate tasks in bulk, apply filtering and sorting options when it is needed.