Tuesday, April 24, 2018

Sitecore Experience Commerce - No commerce data in Sitecore indexes

After creating a catalog with product/category data and hooking it up to your Storefront site, you might expect the data to start appearing on the front-end. Even after full index rebuilds of the web and master indexes, this was not working as expected for me. The query I was using on the web index was:
commercesearchitemtype_t:"Category"
Which would be expected to return me all categories as defined in the catalog. Likewise the following, should return all products (sellable items):
commercesearchitemtype_t:"SellableItem"
 In my case I had changed the environment name from "HabitatAuthoring", and had updated the defaultEnvironment setting. However there are a number of index related settings which require the updated environment as well. The following patch file if applied should correctly connect the Sitecore indexer up with the correct commerce environment.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore role:require="Standalone or ContentDelivery or ContentManagement">
        <contentSearch>
            <indexConfigurations>
                <indexUpdateStrategies>
                    <sellableItemsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </sellableItemsIntervalAsynchronousStrategyMaster>
                    <sellableItemsIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.SellableItemsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </sellableItemsIntervalAsynchronousStrategyWeb>
                    <categoriesIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CategoriesIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </categoriesIntervalAsynchronousStrategyMaster>
                    <categoriesIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CategoriesIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </categoriesIntervalAsynchronousStrategyWeb>
                    <catalogsIntervalAsynchronousStrategyMaster type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CatalogsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </catalogsIntervalAsynchronousStrategyMaster>
                    <catalogsIntervalAsynchronousStrategyWeb type="Sitecore.Commerce.Engine.Connect.Search.Strategies.CatalogsIntervalAsynchronousStrategy, Sitecore.Commerce.Engine.Connect">
                        <Environments hint="list">
                            <environment patch:instead="environment">MyAuthoring</environment>
                        </Environments>
                    </catalogsIntervalAsynchronousStrategyWeb>
                </indexUpdateStrategies>
            </indexConfigurations>
            <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
                <indexes hint="list:AddIndex">
                    <index id="sitecore_master_index">
                        <locations hint="list:AddCrawler">
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.SellableItemsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CategoriesCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                        </locations>
                    </index>
                    <index id="sitecore_web_index">
                        <locations hint="list:AddCrawler">
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.SellableItemsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CategoriesCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                            <crawler type="Sitecore.Commerce.Engine.Connect.Search.Crawlers.CatalogsCrawler, Sitecore.Commerce.Engine.Connect">
                                <Environments hint="list">
                                    <environment>MyAuthoring</environment>
                                </Environments>
                            </crawler>
                        </locations>
                    </index>
                </indexes>
            </configuration>
        </contentSearch>
    </sitecore>
</configuration>

No comments:

Post a Comment