This topic provides general guidelines and recommendations for implementing Optimizely Commerce solutions. The recommendations are based on common scenarios and input from implementation projects.
The purpose of these guidelines is to ensure stability and the best possible performance for your Commerce implementation. Most projects, especially first-time projects done by development teams with limited Commerce experience, are better off following proven recommendations to avoid mistakes, technical debt, as well as performance and scalability issues.
Before making any exceptions from implementation recommendations, ensure that you have a solid understanding of the underlying framework. Deviating from the recommended way of doing things may create more work than necessary, and make future upgrades more difficult. See the Commerce Developer Guide to learn more about the Commerce framework.
Plan project carefully
Commerce projects often take more time than originally estimated due to the complexity of areas like pricing, external integrations, and shipping and payment providers. Allow enough time for planning and design, and start small. Especially for first-time complex projects, it is recommended to do a proof-of-concept first, with a complete order process in place.
Document code changes
When altering workflows or other downloadable code that is added to your solution, make it a habit to clearly comment and document the code in the project. Well-documented code maintained in separated modules makes future system upgrades much easier.
Spend time on catalog design
Start early with the catalog modeling, since this can be complex and often requires more design than originally realized. Let the website catalog hierarchy guide your catalog structure, and limit the number of variants/SKUs associated with each product to avoid performance implications.
See Guidelines for working with catalogs for information about catalog modeling.
Use the search API
The built-in search API is useful especially for category landing pages and large catalog structures. It ensures better website performance, offloads database search and retrieval procedures, and provides paging and facets functionality. See Search.
Set search options correctly
The metafield/model field search options are often misunderstood and misused. Two typical examples are:
- Tokenize. This is often overused even for fields that do not need to be searchable.
- IncludeValuesInSearchResults. Overuse of this adds unnecessary bulk to the search index.
Turn on catalog caching
You should have a clear strategy for caching. Either turn catalog caching on, or implement your own solution. Consider this especially for pricing, and warehouse and inventory updates. See Caching.
Understand StoreHelper and CartHelper
Store helpers are useful, but you need to understand how they work before using them. You can download helper classes here (requires login). These can be modified to suit your needs, for instance by adding caching and other logic. As an example, the StoreHelper has no caching for prices, so this needs to be added.
Other limitations to helper implementations are, for instance, that CartHelper does not allow a variant/SKU to be added multiple times as multiple line items. Regarding ownership of business logic, for StoreHelper use the ReadOnlyPricingLoader instead. For CartHelper, download the code and make it "your own."
Use the payment and shipment provider models
When implementing payment processing and shipping rate calculation, use the provider model. This makes them available in Commerce, and includes storage for configuration settings. See Payments and Shipping.
Avoid database modifications
Modifying the database includes editing or deleting database tables and stored procedures. This can break functionality and prevent future upgrades.
Minimize use of MetaImage
The MetaImage metafield is used for storing images. If you use this metafield type in catalog meta-classes, it works for smaller, low-traffic websites, but is inefficient for larger websites as the output is stored in the database. Also, it is not accessible outside of an entry. However, the MetaImage meta-field performance was improved recently.
Last updated: Sep 28, 2021