Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Scheduled jobs (dev)

Describes scheduled jobs in Optimizely Commerce Connect.

Scheduled jobs run in the background at preset time intervals and typically do cleanup and batch-updating tasks.

A default Optimizely Commerce Connect installation has several predefined scheduled jobs managed from the Optimizely Content Management System (CMS) administration interface. See Schedule jobs through the UI and Schedule jobs through code.

Classes for scheduled jobs are available in the following namespaces:

  • EPiServer.Business.Commerce.ScheduledJobs
  • ScheduledJob and ScheduledJobCollection classes of the EPiServer.DataAbstraction namespace in Optimizely CMS.

Default scheduled jobs

A sample Commerce Connect installation contains the predefined scheduled jobs, as described in the following sections.

Remove expired carts

Removes expired carts, meaning they have not been accessed for a specified number of days. The default value is 30. Configure this in the ExpiredCartJobDays property of the appSettings.json file.

Control the name of carts to be excluded from removal through 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.

Find catalog URI conflicts

Analyze 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 URI.

Shipment releasing

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 hour after an order is placed. Change the value in the appsettings.json file by setting the shipmentAutoReleaseTimeout property value.

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 Connect databases. When the job is launched (manually or automatically), it rebuilds or reorganizes depending on the current fragmentation percentage.

Run the job manually anytime you notice a performance degradation. Or, schedule it to run at regular intervals. If possible, run the job at times of low usage. Set the following parameters to launch the job automatically when specified fragmentation levels are met.

ParameterDescriptionChanging the default value
HighFragmentationThresholdIf the average fragmentation in percent of an index is larger than this value, the index is rebuilt. Default value: 30%Add a setting to the commerce section of appsettings.json file using the key EPiServer::Commerce::HighFragmentationThreshold.
LowFragmentationThresholdIf the average fragmentation in percent of an index is larger than this value, and smaller than or equal to the HighFragmentationThreshold value, the index is reorganized. Default value: 10%Add a setting to the commerce section of appsettings.json file using the key EPiServer::Commerce::LowFragmentationThreshold.
DataBaseIndicesJobCommandTimeOutThe maximum number of seconds for which you want the job to run. The system generates an exception if the job does not finish within that time. Default value: 30 secondsAdd a setting to the commerce section of appsettings.json file using the key EPiServer::Commerce::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 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 from the Sales By Day report.

Collect orders per promotion statistics

This job reworks the promotion (discounts) statistics collection for orders associated with campaigns in the Marketing page in Commerce Connect.

This page 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 improves performance for the display of these statistics.

Run the Collect orders per promotion statistics job to migrate your promotions system to use the 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 ones. To force the refreshing of their data, add the appSettings key episerver:commerce.ReportForInactivePromotionItems and set it to true.

Archived schedule job

This job deletes archived items permanently after a set period of time. Run this job manually if needed.

Order per hour schedule job

This job collects and saves order data by hour.

ParameterDescriptionChanging the default value
ShipmentsBatchSizeHandles the number of shipment data per batch. Default value: 10000Add a setting to the Commerce section of appsettings.json using the key EPiServer::Commerce::ShipmentsBatchSize.
ReturnedItemsBatchSizeHandles the number of returned items per batch. Default value: 10000Add a setting to the Commerce section of appsettings.json using the key EPiServer::Commerce::ReturnedItemsBatchSize.

Other scheduled jobs

These jobs are available if you have Optimizely Campaign, or the Optimizely Service API in your implementation.

Export product feed

Exports the entire product feed (catalog) for 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 Product Recommendations. This job updates product changes without exporting the entire catalog.

This job is faster than the full product feed export job because changes only include added and updated products. However, the incremental export job does not replace the full export job, because deletion of products and edits to asset and inventory information are not included.

Export product data to Optimizely Campaign

This job collects product data and saves it to a .csv file for data transfer to Optimizely Campaign. See Commerce Connect + Campaign.

Remove old Service API uploaded files and directories

The Optimizely Service API is used for importing large files such as Commerce Connect catalogs. The Service API provides a method for deleting uploaded files that are no longer needed. If the Delete chunk uploaded method is overlooked, use this scheduled job to clean up obsolete files.

The job, which is only available after installing the Service API, removes temporary uploaded files and directories older than several configured days. Set the value in the appsettings.json commerce section, using episerver:serviceapi:uploadRetentionPeriod. The default is 30 days if there is no configuration value.