Extending Sitecore Commerce Connect

15
Extending Sitecore Commerce Connect Framework & Best Practices Kautilya Prasad Sitecore Commerce Connect Framework

Transcript of Extending Sitecore Commerce Connect

Page 1: Extending Sitecore Commerce Connect

Extending Sitecore Commerce Connect Framework & Best Practices

Kautilya Prasad

Sitecore Commerce Connect Framework

Page 2: Extending Sitecore Commerce Connect

On the menu…• Common customization requirements.• How to extend the synchronization provider?• How to extend the product base class?• How to implement incremental product sync?• Best practices• Q&A

Sitecore Commerce Connect Framework

Page 3: Extending Sitecore Commerce Connect

Common Customization Requests

• Extend product class to add custom properties• Discontinue sync if the ERP Integration jobs are still

running.• Check the ECS indexes are up to date before running

the sync.• Sync already running alert.• “Are you sure” button.• License check.• Custom Logging.• Post synchronization tasks – Email and statistics• Implement Incremental Product Sync.

Sitecore Commerce Connect Framework

Page 4: Extending Sitecore Commerce Connect

How to extend the product sync provider?• OOTB Provider:

Sitecore.Commerce.Services.Products.ProductSynchronizationProvider• SynchronizeProducts(SynchronizationRequest request)• SynchronizeArtifacts(SynchronizationRequest request)

• Extend the provider by creating a custom class• Check Preconditions, Add custom logic • Stop execution if the preconditions are not met. Display message on UI using status updater• If all dependencies are passed, pause the indexes present in the OOTB setting

“ProductSynchronization.ProductIndexes”• Disable the index using Settings.Indexing.Enabled = false;• Run the pipeline “commerce.synchronizeProducts.synchronizeProducts”• Clear the cache• Enable the index using Settings.Indexing.Enabled = true; • Do post synchronization tasks (send emails, write to custom properties table, kick off other jobs etc..)

Sitecore Commerce Connect Framework

Page 5: Extending Sitecore Commerce Connect

How to extend the product base class?Support Custom Product Properties

• OOTB Repository: Sitecore.Commerce.Data.Products.ProductRepository

• Add the custom template to sitecore product template inheritance.• Define a class with your custom properties, inherit from commerce product

class

Sitecore Commerce Connect Framework

Page 6: Extending Sitecore Commerce Connect

How to extend the product base class?.. continued

• Create a custom repository

Sitecore Commerce Connect Framework

Page 7: Extending Sitecore Commerce Connect

How to extend the product base class?.. continued

• Add logic to populate the custom fields

Sitecore Commerce Connect Framework

Page 8: Extending Sitecore Commerce Connect

How to extend the product base class?.. continued

• Config Changes• Replace the base commerce product class with the new custom class.• Change the repository type to new type.

Sitecore Commerce Connect Framework

Page 9: Extending Sitecore Commerce Connect

Incremental Product Sync

• Get External Ids from Commerce Repository• commerce.synchronizeProducts.getSitecoreProductList

Get Products List From Sitecore

• Get External Ids from ECS• commerce.synchronizeProducts.getExternalCommerceSystemProductList

Get Products List From ECS

• Products to Delete from Sitecore;Products to Update/Create in Sitecore• EvaluateProductListUnionToSynchronize

Intersect and Except

Page 10: Extending Sitecore Commerce Connect

Incremental Sync.. continued•<commerce.synchronizeProducts.synchronizeProductList>• Prepares all data to be inserted, deleted, etc• Override EvaluateProductListUnionToSynchronize. Add a new property

in the request object that holds a dictionary of products and their last modified timestamp.

Page 11: Extending Sitecore Commerce Connect

Incremental Sync.. Continued•<commerce.synchronizeProducts.synchronizeProducts>• Reads the data to be synched and calls the update/ delete

methods• Override

Sitecore.Commerce.Pipelines.Products.SynchronizeProductList.SynchronizeProductList class.

Page 12: Extending Sitecore Commerce Connect

Incremental Sync.. continued

Page 13: Extending Sitecore Commerce Connect

Best practices• Check if the processor that gives the list of number of items available

in sitecore commerce repository is returning correct count.• Long time to finish the sync.• You see the same product being added to repository and deleted from another

bucket level.• Logs say that only 500 products found in Sitecore while there are 20K products.

• Check if the index is updated after every Sync. I log the last build time and email it for records.• Record history of product synchronization run, helps in troubleshooting.• Use repositories to extend the framework.• Implement incremental sync for better performance.• Limit the access to Product Repository to only few users.• Don’t build the website catalog navigation from product repository.

Sitecore Commerce Connect Framework

Page 14: Extending Sitecore Commerce Connect

Q&A

Page 15: Extending Sitecore Commerce Connect

http://www.xcentium.com/en/Blog/author/Kautilya-Prasad