Try our conversational search powered by Generative AI!

How to access products in the catalog?

Vote:
 

Hi Folk!

I am pretty new to EPiServer, MVC and .NET so I would appreciate if you could specify all the steps when answering.

I have currently I fresh install of EPiServer 7 and EPiServer Commerce. I have already created 1 catalog named "Results" with 3 products "Product 1",   "Product 2" and "Product 3" and I would like to know how to access those products within my source code.

I have read the documentation but it didn't really helped me so far so I would really appreciate if you could provide me the necessary lines of code to get access to the EPiServer Commerce instance in order to get the instances of the products.

Thank you in advance for your valuable help!!

Daniel 

#64944
Jan 16, 2013 17:19
Vote:
 

Hi Daniel!

Mediachase.Commerce.Catalog.CatalogContext is the main class to remember when working with catalog entries, nodes and catalogs.

CatalogContext.Current gets the current instance of the catalog system, and using this instance you can retrieve the entries (or the catalog) that you mention.

The basic usage to retrieve a catalog entry:

var catalogEntry = CatalogContext.Current.GetCatalogEntry("Product1Code");

Where Product1Code is the identifier assigned by you upon creation in the manager (or via the API). You can also use the database autoincremented id to retrieve objects (an overload for GetCatalogEntry).

You should read Roger Cevungs articles to get a better insight, starting with http://world.episerver.com/Articles/Items/Catalog-Entry-loading-and-ResponseGroups-in-EPiServer-Commerce/.

 

Good luck!

#64999
Jan 17, 2013 11:11
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.