This topic describes scheduled jobs in Episerver Commerce. Scheduled jobs run in the background at preset time intervals and typically do cleanup and batch updating tasks.
How it works
A default Commerce installation has several predefined scheduled jobs, which are managed from the Episerver CMS administration interface.
You can also add custom scheduled jobs, see Scheduled jobs in the CMS Developer Guide.
Classes for scheduled jobs are available in the following namespaces:
- ScheduledJob and ScheduledJobCollection classes of the EPiServer.DataAbstraction namespace in Episerver CMS.
Default scheduled jobs
A sample installation of Episerver Commerce contains the predefined scheduled jobs as described in the following.
Remove expired carts
Removes carts that are expired, meaning they have not been accessed for a specified number of days. The default value is 30. This can be configured in the ExpiredCartJobDays property of the appSettings file.
You can also control the name of carts to be excluded from removal via the appSetting key episerver:ExpiredCartsRemovalJobExcludedCartName. The default value is "Wishlist".
Full search index
Performs a full indexing of content in product catalogs.
Incremental search index
Performs an incremental indexing of content in product catalogs.
Draft store migration
Used for migration of previously published content versions, when upgrading to the version management introduced with Commerce 9. See Commerce 9 - upgrading and migration.
Find catalog URI conflicts
Analyzes the database to find entries and categories that have the same Name in URL under the same parent category. If conflicts are found, they are logged as warnings, output to the Scheduled Job Log, and sent to email addresses specified in the episerver:commerce.UriSegmentConflictsEmailRecipients AppSetting. For details, see URL segment and SEO URL.
Searches for releasable shipments in active orders. If the difference between the shipment creation time and the current time is greater than the configured time span, the shipment status for the order is changed to Released.
By default, when the job is activated, order shipments are released one day after an order is placed. The value can be changed changed in the <Siteroot>/Configs/ecf.order.config file by editing the shipmentAutoReleaseTimeout element.
Rotate encryption keys
Sensitive customer data is secured with encryption keys that are set in meta-fields. This job rotates the encryption keys used by the system.
Maintain database indexes
This job rebuilds or reorganizes database indexes, to reduce fragmentation in the CMS and Commerce databases. When the job is launched (manually or automatically), it rebuilds or reorganizes depending on the current fragmentation percentage.
You can run the job manually any time you notice a degradation in performance. Or, you can schedule it to run at regular intervals. If possible, the job should be run at times of low usage. You can also set the following parameters to launch the job automatically, when specified fragmentation levels are met.
|Parameter||Description||Default value||Changing the default value|
|HighFragmentationThreshold||If the avg_fragmentation_in_percent of an index is larger than this value, the index is rebuilt.||30%||Add a setting to the web.config's appSettings section using the key episerver::HighFragmentationThreshold.|
|LowFragmentationThreshold||If the avg_fragmentation_in_percent of an index is larger than this value, and smaller than or equal to the HighFragmentationThreshold value, the index is reorganized.||10%||Add a setting to the web.config's appSettings section using the key episerver::LowFragmentationThreshold.|
|DataBaseIndicesJobCommandTimeOut||The maximum number of seconds for which you want the job to run. If the job does not finish within that time, an exception is generated.||30 seconds||Add a setting to the web.config’s appSettings section using the key episerver::DataBaseIndicesJobCommandTimeOut. Within this appsetting setting, set the value to the maximum number of seconds for which you want the job to run.|
Collect subscription data for reports
This job collects subscription data, ensuring that recurring payments are regularly generated as a background process. Used for payment plans, such as magazine or grocery subscriptions.
Collect order data for reports
This job compiles the data used in the Sales By Day report.
Collect orders per promotion statistics
This job reworks the collection of promotion (discounts) statistics for orders associated with campaigns in the Marketing view in Commerce.
This view displays discounts for an order, the number of orders that use each discount, and the total number of orders that include discounts. The calculation rework is done to improve performance for the display of these statistics.
Run the Collect orders per promotion statistics job to migrate your promotions system to use the new optimization. If campaigns have too many orders, you may get a timeout exception when running the job. If you do, add the appSettings key episerver:commerce.OrderPerPromotionReportDataTimeout, and set the timeout in seconds.
By default, this optimization ignores inactive and expired campaigns and promotions, although they are migrated along with active campaigns and promotions. If you want to force the refreshing of their data, add the appSettings key episerver:commerce.ReportForInactivePromotionItems and set it to "true".
Other scheduled jobs
Export product feed
Exports the entire product feed (catalog) for the Episerver Product Recommendations, to provide updated information to the recommendation service. This job includes all changes, including deletion of products and edits to asset and inventory information.
Export product feed incrementally
Exports the product feed (catalog) incrementally to Episerver Product Recommendations. This job updates product changes without exporting the entire catalog.
This job is faster than the full product feed export job, since changes only include added and updated products. However, the incremental export job does not replace the full export job, since deletion of products and edits to asset and inventory information are not included.
Export product data to Episerver Campaign
Remove old Service API uploaded files and directories
The Episerver Service API is used for importing large files such as Commerce catalogs. The Service API provides a method for deleting uploaded files that are no longer needed. You can use this scheduled job to clean up obsoleted files in case the Delete chunk uploaded method is overlooked.
The job, which is only available after installing the Service API, removes temporary uploaded files and directories that are older than a number of configured days. The value can be set under appSettings in the web.config file, using episerver:serviceapi:uploadRetentionPeriod. If there is no configuration value, the default is 30 days.
Last updated: Feb 10, 2021