# Sitecore CM/CD setup Note: This hasn't been tested with SiteCore managed cloud yet. ## CM setup - install Sitecore - create seperate daterbase for Ucommerce - add reference to database in ConnectionStrings.config - install Ucommerce via the Sitecore installation wizard ## CD setup - install Sitecore - change role to ContentDelivery in web.config `<add key="role:define" value="ContentDelivery" />` - Remove connectionstring to master database - `<!--<add name="master" connectionString="user id=sa;password=H3mm3ligT;Data Source=.;Database=sct-2_Sitecore.Master" />-->` - Add connectionstring to the Ucommerce database from the CM environment - `<add name="ucommerce" connectionString="user id=sa;password=H3mm3ligT;Data Source=.;Database=sct-1_Ucommerce" />` - Copy Ucommerce files into the folderstructure - add assemblies called Ucommerce.*.dll to bin folder - add the /bin/ucommerce folder - Add Ucommerce folder to "sitecore modules/Shell" - Add the ucommerce files from App_Config/Include - Disable Sitecore.uCommerce.initialize.config - Disable Sitecore.uCommerce.Pipelines.ModifyPipelines.config - Disable Sitecore.uCommerce.Databases.config - Disable Sitecore.uCommerce.Dataproviders.config - In sitecore modules/Shell/Ucommerce/Configuration/Shell.config change nameOfContentDatabase to web `<nameOfContentDatabase>web</nameOfContentDatabase>` - Make changes to web.config - Add near top (at line 7 in my case) ``` <section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache, Version=5.5.0.0, Culture=neutral, PublicKeyToken=6876f2ea66c9f443" requirePermission="false"/> <section name="clientDependency" type="ClientDependency.Core.Config.ClientDependencySection, ClientDependency.Core, Version=1.8.2.1" requirePermission="false"/> ``` - Add to `<modules runAllManagedModulesForAllRequests="true">` (line 88 in my case) ``` <add name="ClientDependencyModule" type="ClientDependency.Core.Module.ClientDependencyModule, ClientDependency.Core, Version=1.8.2.1, Culture=neutral"/> ``` - Add to `<handlers>` (line 113 in my case) ``` <add verb="*" path="PaymentRequest.axd" preCondition="integratedMode" name="PaymentRequest" type="Ucommerce.Transactions.Payments.PaymentRequestForm, Ucommerce"/> <add verb="*" path="PaymentProcessor.axd" preCondition="integratedMode" name="PaymentProcessor" type="Ucommerce.Transactions.Payments.PaymentProcessor, Ucommerce"/> <add verb="*" name="ClientDependency" preCondition="integratedMode" path="DependencyHandler.axd" type="ClientDependency.Core.CompositeFiles.CompositeDependencyHandler, ClientDependency.Core, Version=1.8.2.1, Culture=neutral"/> ``` - Add to `<controls>` (line 143 in my case) ``` <add tagPrefix="commerce" namespace="Ucommerce.Presentation.Web.Controls" assembly="Ucommerce.Presentation"/> ``` - Change `<compilation>` (line 190 in my case) ``` <compilation defaultLanguage="c#" debug="true" targetFramework="4.7"> ``` - Add assembly (line 203 in my case) ``` <add assembly="ClientDependency.Core, Version=1.8.2.1, Culture=neutral"/> ``` - Add assemblies (line 386 in my case) ``` <dependentAssembly> <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc"/> <codeBase version="4.4.0.0" href="bin\ucommerce\Castle.Core.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Castle.Windsor" publicKeyToken="407dd0808d44fbdc"/> <codeBase version="5.0.0.0" href="bin\ucommerce\Castle.Windsor.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="ClientDependency.Core"/> <codeBase version="1.8.2.1" href="bin\ucommerce\ClientDependency.Core.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="FluentNHibernate"/> <codeBase version="2.1.2" href="bin\ucommerce\FluentNHibernate.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="NHibernate.Caches.SysCache" publicKeyToken="6876f2ea66c9f443"/> <codeBase version="5.5.0.0" href="bin\ucommerce\NHibernate.Caches.SysCache.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4"/> <codeBase version="4.0.4" href="bin\ucommerce\Iesi.Collections.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a"/> <codeBase version="1.2.11.0" href="bin\ucommerce\log4net.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Infralution.Licensing" publicKeyToken="3e7e8e3744a5c13f"/> <codeBase version="4.7.1.0" href="bin\ucommerce\Infralution.Licensing.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="AuthorizeNet"/> <codeBase href="bin\ucommerce\AuthorizeNet.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Braintree-2.22.0"/> <codeBase href="bin\ucommerce\Braintree-2.22.0.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="paypal_base"/> <codeBase href="bin\ucommerce\paypal_base.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Lucene.Net" publicKeyToken="85089178b9ac3181"/> <codeBase version="3.0.3.0" href="bin\ucommerce\Lucene.Net.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Lucene.Net.Contrib.Spatial.NTS" publicKeyToken="85089178b9ac3181"/> <codeBase version="3.0.3.0" href="bin\ucommerce\Lucene.Net.Contrib.Spatial.NTS.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="ICSharpCode.NRefactory.CSharp" publicKeyToken="d4bfe873e7598c49"/> <codeBase version="5.0.0.0" href="bin\ucommerce\ICSharpCode.NRefactory.CSharp.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="d4bfe873e7598c49"/> <codeBase version="5.0.0.0" href="bin\ucommerce\ICSharpCode.NRefactory.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Esent.Interop" publicKeyToken="8dd49bbdae3f61af"/> <codeBase version="1.7.0.0" href="bin\ucommerce\Esent.Interop.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Spatial4n.Core.NTS" publicKeyToken="9f9456e1ca16d45e"/> <codeBase version="0.3.0.0" href="bin\ucommerce\Spatial4n.Core.NTS.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Remotion.Linq" publicKeyToken="5fa384605d304122"/> <codeBase version="2.2.0.0" href="bin\ucommerce\Remotion.Linq.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Remotion.Linq.EagerFetching" publicKeyToken="5fa384605d304122"/> <codeBase version="2.2.0.0" href="bin\ucommerce\Remotion.Linq.EagerFetching.dll"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-5.2.5.0" newVersion="5.2.0.0"/> </dependentAssembly> ``` - Add `<syscache>` to web.config right before the end of the configuration file. ``` <syscache> <!-- Cache catalog objects for 60 mins before refreshing --> <cache region="CatalogFoundation" expiration="3600" priority="5"/> <cache region="MarketingFoundation" expiration="3600" priority="5"/> <cache region="SecurityFoundation" expiration="3600" priority="5"/> <cache region="Backend" expiration="3600" priority="5"/> </syscache> <location path="ucommerceapi"> <system.web> <httpHandlers> <add path="*" type="Ucommerce.Sitecore.Web.SessionHttpHandlerFactory, Ucommerce.Sitecore" verb="*"/> </httpHandlers> </system.web> </location> <clientDependency version="20195" fileDependencyExtensions=".js,.css"> <compositeFiles defaultProvider="defaultFileProcessingProvider" compositeFileHandlerPath="~/DependencyHandler.axd"> <fileProcessingProviders> <add name="CompositeFileProcessor" type="ClientDependency.Core.CompositeFiles.Providers.CompositeFileProcessingProvider, ClientDependency.Core, Version=1.8.2.1" enableCssMinify="true" enableJsMinify="true" persistFiles="true" compositeFilePath="~/App_Data/TEMP/ClientDependency" urlType="Base64QueryStrings" pathUrlFormat="{dependencyId}/{version}/{type}"/> </fileProcessingProviders> </compositeFiles> </clientDependency> <location path="sitecore modules/Shell/ucommerce"> <system.web> <httpRuntime maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" relaxedUrlToFileSystemMapping="true" requestValidationMode="2.0"/> </system.web> </location> ``` - Register a custom implementation of ISitecoreContext as a new app in the apps folder. https://docs.ucommerce.net/ucommerce/v9.2/extending-ucommerce/register-a-component.html - In the configuration of this component, the nameOfContentDatabase parameter should be changed to 'web'. The implementation needs to override a hardcoded master database in ISitecoreContext: ```` using Sitecore.Configuration; using Sitecore.Data; using Ucommerce.Sitecore.Extensions; using Ucommerce.Sitecore.SitecoreDataProvider; namespace Ucommerce.Sitecore { /// <summary> /// Sitecore Context implementation. /// </summary> public class SitecoreContext : ISitecoreContext { private string NameOfContentDatabase { get; set; } public SitecoreContext(string backEndDomainName, string nameOfContentDatabase, bool shouldPullTemplatesFromSitecore) { BackendDomainName = backEndDomainName; NameOfContentDatabase = nameOfContentDatabase; ShouldPullTemplatesFromSitecore = shouldPullTemplatesFromSitecore; } public virtual Database MasterDatabase { get { return DatabaseForContent; } } public virtual Database DatabaseForContent { get { return Factory.GetDatabase(NameOfContentDatabase); } } public DataProviderMasterDatabase DataProviderMaster { get { return MasterDatabase != null ? MasterDatabase.GetUcommerceDataProvider() : null; } } public string BackendDomainName { get; private set; } public bool ShouldPullTemplatesFromSitecore { get; private set; } } } ```` ```` <configuration> <components> <component id="SitecoreContext" service="Ucommerce.Sitecore.ISitecoreContext, Ucommerce.Sitecore" type="Ucommerce.Sitecore.SitecoreContext, Ucommerce.Sitecore"> <parameters> <backEndDomainName>sitecore</backEndDomainName> <nameOfContentDatabase>web</nameOfContentDatabase> <shouldPullTemplatesFromSitecore>false</shouldPullTemplatesFromSitecore> </parameters> </component> </components> </configuration> ````` Please note that the implementation and registration needs to have your own namespace + assembly specifiction as specified in documentation article: https://docs.ucommerce.net/ucommerce/v9.2/extending-ucommerce/register-a-component.html