550 likes | 572 Views
Explore the Litium CMS domain model for websites, pages, and blocks. Learn to create reusable content snippets, manage global instances, and utilize the BlockModel entity. Enhance your development skills in product information management, customer relations, media handling, and search functionalities.
E N D
Domain model • Pages can be “active” in different channels • DraftPage is similar to Page, is the working copy
Blocks • New independent entity from L7 • Has data modelling • Can be marked as • Global = true -> web pages that uses the block has reference to a “global instance” • Global = false -> web pages that uses the block has its own “block instance” • View as “Information snippets” • That can be “reused” in the same web page (global = false blocks) • That can be “reused” across web pages (global = true blocks) • Can be “moved” (visual location) inside the “Container”
In the accelerator usual reference is to the BlockModel Note that BlockModel only contains the SystemId of the Block (Similar to all other related entities in Litium API)
Data model Litium 5 Product Base product Information common to all variants. Variant Variant specific information. Price Inventory
Data model Litium 5 Product Field template Base product level - Name - Description … Variant level - Color - Size … Base product Information common to all variants. Article number* Field template Variant Variant specific information. Articlenumber* * Article number - Mandatory system field - Both levels base product and variant
Data model Litium 5 Assortment Categories Channel Published Product One is main category List
Data model Litium 5 Relations between products and categories Product Categories Base product Relation Variant Relation Relationship types Directional “Accessories” Bi-directional “Similar products” Relation
Display templates • Possible to use different template per website • ASP.NET WebForms or ASP.NET MVC 5 • Products can use either base product url or variant url
Extend PIM • Replace implementation logic • IPriceCalculator • IStockStatusCalculator
Customers (Relations module) • A registry of customers, groups & organizations • Registering a new customer • Accelerator creates a new customer from checkout page if “create account” checkbox is selected when creating an order • RegisterNewUser() method in Src\Litium.Accelerator\Services\CheckoutServiceImpl.cs
Media • Images and files stored here • Physically images are in the “Files folder” • Use CommonFilesDirectory in multiserver scenarios • Products need to be enriched with respective images: ”media mapping” • Use media mapper addOn • Without media mapper addon • Write custom code to map the image
Media • How to create a folder template and a folder from codehttps://docs.litium.com/documentation/developer-guides/media/creating-a-media-folder-field-template-and-a-folder • Giving access permission to folderhttps://docs.litium.com/documentation/developer-guides/media/adding-permissions-to-a-media-folder
Search • Litium uses Lucene as search engine • Search query • Conditions: Or / Exclude / Range • Paging, sorting • TagTerms • To view indexed values • Indexfiles stored in files directory • https://docs.litium.com/documentation/architecture/search
Administration UI • Rewrite in PIM • Angular • ASP.NET WebAPI • Signalr
Litium is based on standard technology • ASP.NET Core (Microsoft/Open Source) • Dependency injection • Logging • Configuration • Entity Framework Core (Microsoft/Open Source) • Newtonsoft JSON (Open Source) • AutoMapper (Open Source) • ASP.NET MVC 5 (Microsoft) • ASP.NET WebAPI 5 (Microsoft) • Angular JS (Google/Open Source)
Eco system PAYMENTS PRICE COMPARISON SEARCH & RECOMMENDATIONS SEO & CONVERSION ANALYTICS + and more EMAIL MARKETING PREMIUM PIM CUSTOMER SERVICE PRINT SOCIAL MARKETING AdobeInDesign + and more ERP + and more
AddOns • Following are some of the most frequently used AddOns • Product Media Mapper • To connect images and files to products automatically • Payment providers • Klarna, Dibs, PayEx, Adyen, PayPal, Nets, Handelsbanken Ecster, Skrill • Integration kit • Platform to develop file based integrations towards Litium
Integration Integration Kit InRiverConnector ERP / PIM / CRM Product info Images & media Order status Delivery status Customer Info Stock balance Prices Credit limits Order Payments Customer Info etc. https://kc.litiumstudio.se/more/best-practices/integrate/best-practice-for-integration-architecture
Audit • Logging of updates • Update log
Error handling • Unhandled errors are logged in • In web requests– this.WebLog() (Exceptional) • In background tasks– this.Log() • Handled errors should be logged by the developer. • Always log the exception when logging in try/catch
Error handling • Event log • Logging to a file
WebLog • Built on StackExchange Exceptional • Logs the whole web-request
Service bus • Used to send messages between applications. • Local on application if no Service Bus is configured • Queue outside application • Processed even if application restarts • Free up resources by running queue in the background • Two different types of message queues • Queue – Same message queue for all applications • Topic – Unique queue for each application • Used in all multi-server solutions • Web farms for load balancing • Multiple developers towards same database • Note: Servers are updated “Near real time”
Task: Service Bus New questionsshould not be addedinstantly to the FAQ page butweneed to monitor submittedsubmittedquestions to manuallyupdate the questiondatabasewhenneeded. • See the example on https://docs.litium.com/documentation/architecture/service-bus and create a new Queue in FAQService • Add the methodSubmitQuestion(string question) to IFAQService and implement it in FAQService, the messageshouldsend the postedquestion to yourqueue. • ImplementmethodProcessQueueMessage (see KC for example) in FAQService and in thismethodwrite a Info levelmessage to Litium event log • In the Index methodofFAQController post a new question, thenload the page and verifythat the question gets written to the log. Optional • Removepostingofquestion on page load and insteadcreate a form with a textbox and button on the FAQ page and use it to submit new questions. • Installpapercut (and set smtp to 127.0.0.1 in web.config) and send a mail on every new questioninsteadof just writing to log, injectIMailService in FAQService and use it to send the mail.
Event system • All events are handled by a an EventBroker (publish/subscribe) • All events are triggered by the application • All events are local • i.e. in a multi server environment, if an entity is changed in one server, its changed event is raised only in that server. • If not declared otherwise explicitly (set scope when publishing event, remote scope sends via service bus to all applications)
Event system (new API) • All events have its own class. • The domain object is a parameter in the event handler method. • EventBroker can be used in the project to write your own events, or to listen or to trigger existing events.
Litium.Validation.IValidationRule Business rules validation (new API) • New validation framework for business rules.
Task: Validateurl • Ourclientneed to prevent the usageof ÅÄÖ in producturls, weneed a validation to preventusers from addingthesecharacters. Create the classValidateVariantUrl in namespaceLitium.Accelerator.Validationsthatinherits from Litium.Validations.ValidationRuleBase<Variant> and implement the method the interitancerequires • In the methodverifythat the charactersåäöare not present in the url (useentity.GetUrl(ModuleCMS.Instance.WebSites.DefaultWebSiteID) to get url). • GetUrl is an extension methodthatrequire: usingLitium.Foundation.Modules.ExtensionMethods; • Remembernull-check of the urlbeforechecking the value • If incorrecturladd a errormessage in the ValidationResultthat the methodreturns by calling the AddError() method on the ValidationResult • As first parameter in AddError() pass "_url” as parameter, thiswillattach the error to the urlsystemfield in the UI • Open the productGivinTunic Lite in Litium Backoffice > Products, open the propertiestab for any variant and verifythat variants can no longer be updated to a urlcontainingåäö. Optional • Url’sneed to be validated for Categories and BaseProductsalso, useLitium.Validations.ValidationRuleBase<Category> and Litium.Validations.ValidationRuleBase<BaseProduct>, test baseproductusing the productNolita Scarf that has itsurl set on BaseProduct and not on Variant.
Batching data (new API) Litium.Data.DataService.CreateBatch • Framework for handling batches of domain objects to • Delete, create or update • A batch is a single transaction • If one operation fails, the whole batch is rolled back. • All entities in a single batch are logged together in logging for auditing.
Batching data (new API) Litium.Data.DataService.CreateBatch Both baseproduct and variant created in one transaction, if variant fails no baseproduct is created
Querying Litium.Data.DataService.CreateQuery • Querying direct towards database. • Do not use towards public site, without implementing own caching.
Querying Litium.Data.DataService.CreateQuery
Concurrency • Optimistic concurrency is available in Ecommerce area • All other areas do not have concurrency checks • Can enforce pessimistic concurrency through DistributedLock object
Web API • Useful for • RESTful applications • Integration when server is communicating with other servers. • Avaliable since Litium version 5.5 • Service Accounts – Access services without access to Litium Backend • OnlyJwtAuthorization - attribute to restrict API endpoint to only use JSON Web Token (JWT) • OnlyServiceAccountAuthorization – attribute to restrict API endpoint to only allow Service Accounts https://kc.litiumstudio.se/documentation/architecture/web-api
Headless API AddOn • Platform to build integrations via webapi’s • In particular to use external CMS systems with Litium as the Ecommerce processing and PIM data engine • https://docs.litium.com/documentation/add-ons/integration/litium-headless-api
Task: FAQ API • In the Mvc project create Controllers/Api/FaqApiController.cs by copying SampleApiController from https://kc.litiumstudio.se/documentation/architecture/web-api • Inject IFAQService in controller constructor and make the api return questions from the service. Optional – API Security • Create a new servcieaccount in settings • Implement OnlyJwtAuthorization attribute on the controller, use postman to get a JWT token and use the token to get questions.
Upgrading • As with installation, upgrading is done through Visual Studio. • There is no separate upgrading program.
Upgrading • Upgrading data in database is done through upgrading script • Files/Images that are saved in product catalog are moved to the Media Archive upon first application start of Litium 5. • Storage folder structure is also changed during upgrade