November Happy Hour will be moved to Thursday December 5th.

Using Catalog Context outside of web environment

Vote:
 

Is it possible to read / write catalog data (nodes / entries etc.) from a console application outside of the web environment.

I have a requirement to write an application that will read in a catalog entry, re serialize the meta data and save / update, I have been led to believe that simply publishing a catalog entry from the commerce front end will re-serialize the data, this would be fine if it were just a few entries that needed updating but we have nearly 80,000 products and 90% of them need updating. My plan is to run the app overnight and have it update / re serialize the entry data for all entries in the catalog.

I downloaded the catalog indexer sample package but that hasn't been updated to the IOC pattern so I am unable to use it outside of the web context.

We have also tried the bulk update within the commerce front end but that only seems to update the first 20 data items and ignores the rest, even if you are viewing 1000 entries it will only save the top 20 entries within the page of data being displayed, this is obviously possible to use but 80,000 products 20 at a time seems like serious overkill.

I have scoured the web for methods to solve this issue but it seems that if anyone does know how to do it they are keeping it very quiet.

If anyone knows any other methods for bulk updating / re-serializing catalog entry data I would really like to know about them.

Thanks in advance,

Dean Fisher

#90690
Sep 16, 2014 11:54
Vote:
 

Hi,

Yes, it is possible. CatalogImport is an example of doing bulk-catalog operations outside of site context.

I'll come back later with the code of how you register the dependencies for the tool.

And FYI, the bug related to CatalogIndexer is now active and is under fixing.

Regards.

/Q

#90691
Sep 16, 2014 12:01
Vote:
 

Thank you

#90692
Sep 16, 2014 12:10
Vote:
 

Here's something you can do to set up the dependencies, you'll need to add reference to EPiServer.Events.dll and EPiServer.Framework.dll:

public static void InitializeServiceLocator()
{
var container = new Container();
var locator = new StructureMapServiceLocator(container);
var context = new ServiceConfigurationContext(HostType.Installer, container);

context.Container.Configure(ce =>
{
ce.For().Singleton().Use();
ce.For().Singleton().Use();
ce.For().Singleton().Use();
ce.For().Singleton().Use();

ce.For().Singleton().Use()
.Ctor().Is()
.Ctor().Is(new TimeSpan(1, 0, 0));

ce.For().Singleton().Use();
ce.For().Use(() => CatalogContext.Current);
ce.For().Singleton().Use();
ce.For().Singleton().Use();
ce.For().Singleton().Use();
ce.For().Singleton().Use();
ce.For().Add();

ce.For().Use(() => Mediachase.Commerce.Security.SecurityContext.Current);
ce.For().Use(() => CustomerContext.Current);
ce.For().Use(() => FrameworkContext.Current);
});

ServiceLocator.SetLocator(locator);
}

LocalCacheWrapper and NullTypeScanner should be simple, minimalistic implementation of  ISynchronizedObjectInstanceCache and ITypeScannerLookup, for example:

class NullTypeScanner : ITypeScannerLookup
{
public IEnumerable AllTypes
{
get { return new Type[0]; }
}
}

Regards.

/Q

#90787
Sep 18, 2014 4:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.