Dynamic indexing of Commerce Properties

Vote:
 

We are building a new webshop using Optimizely Customizable Commerce. All our products are maintained in an external PIM system, and we are then building integration into Commerce.

When we import data into Commerce, it is possible for us to introduce new product types and especially new attributes on products. Introducing new attributes is not something we will do a lot, but it is something that occurs once in a while. Therefore it is great that we can introduce the attribute in PIM without changing any code in Commerce. We also configure in PIM, which attributes we want to show on the product details page, and in which order we show the attributes.

For this reason, we haven't created C# properties for all product attributes. If we were to code properties in C#, we would loose the flexibility of configuring attributes solely in PIM. We would then need to make  and deploy code changes whenever new attributes were introduced.

Is there any way that we can dynamically index product attributes from Commerce in Optimizely Search & Navigation without creating C# properties for the product attributes? And how will this work when we later search for products and want to have facets on products?

If we look at Optimizely documentation pages like e.g. this page: https://docs.developers.optimizely.com/customized-commerce/docs/overriding-default-conventions, they all assume that there are C# properties for all the attributes that we want to include or exclude from indexing. But we don't have these properties for some of our attributes.

Thank you for your help.

#326430
Aug 02, 2024 9:37
Vote:
 

Hi Anders

You did not explain how you would store the attributes without properties for each attribute.

But it sound like you should try storing the attributes in a list property, with this list being a key-value object. This way you don't need to specify the keys in advance (as coded properties). You simply insert the items that should be shown, in the order you decide (where "you" is the PIM, in this case).

I do not recall if the list property is automatically indexed as a list. If not, you may need to customize the indexing, to project a list. But it can be done, too.

About faceting, I am not sure how it would work out. You might need to do a proof-of-concept on that.

#326480
Aug 03, 2024 17:07
Vote:
 

Hi Stefan

Thank you for your reply.

We are importing data using Service API and the catalog.xml file format. In Catalog.xml we can specify metatypes of all our attributes, so they end up as attributes in the Commerce subsystem. They are also visible as attributes in the Commerce Manager user interface. So they appear to be "real" Commerce properties in the Commerce subsystem.

They are just not available as Content properties, since this require us to create C# properties for all our attributes. We only wanted to do this for some of the properties that we need to work with to make business logic easier to implement. But all information is available throug the PropertyDataCollection Property on the ContentData base class in Optimizely, so we can access all our attributes as well as related metadata this way. We can do this dynamically and then present it to the user, as configured throug PIM.

I understand that I need to create C# Properties for the Content subsystem to function. We will create the properties that we need for CMS content, but that will not necessarily be all the attributes. Some attributes need to be searchable but not necessarily visible on the user inteface.

So I guess my question is, if I can make attributes searchable without needing to create C# properties for them? All the information I need to configure indexing is available in the Commerce subsystem, but how can I use that during indexing? Is Search and Indexing a CMS functionality, where Commerce information is lost unless we surface it as C# properties? 

#326553
Edited, Aug 05, 2024 5:54
Vote:
 

Sounds like you are importing meta fields without code-first properties. That is fine. Have you tried setting SetAllowSearch to true on each of those meta fields (may need to be part of the export XML from PIM? If you do, are the fields indexed automatically?

Alternatively, I suppose you could make a custom indexer convention that iterates through a list of metafields in a specific category/tab (to avoid including other fields that are not dynamic attributes) of a certain Commerce content type. If you can make a variant of EPiServer.Find.ClientConventions.TypeConventionBuilder<T> which selects and adds multiple properties to the indexer convention, then you might be on the right path.

But you will not be able to strongly type your facets. You will need to request them using configured or magic strings, which is also supported by the SDK.

It is actually an interesting task. I would like to hear how it works out for you.

#326573
Aug 05, 2024 17:55
Vote:
 

Hi Stefan

I have been trying to look for ways to use TypeConventionBuilder without having C# properties. I can include fields and exclude fields, but the fields are C# properties. I can also create custom classes to index, but then it indexes the C# properties of these classes.

The TypeConventionBuilder defines Conventions that are later used during indexing operations. But I don't know the data to index until I'm actually indexing an object. So I can't define conventions on start-up time, for something I don't know at startup. The data that I have from PIM, may have changed structure since I last started Optimizely.

I need some way of hooking into the indexing process at indexing time. And then define the properties to index at indexing time. Not on startup time.

Does it make sense what I'm trying to write (and to achieve)?

#326659
Aug 07, 2024 10:59
* 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.