3

I need to build a pretty articulated custom commerce product's model but I have found some strange difficulties doing this, which I didn't expect.

An example: I have a product model with a correlated entity which is basically an item with two fields: a code (number) and a description.

To handle this simple scenario, I made a few attempts:

I made a simple model with Sitecore using template , the result was perfect but those items would not be linked with the commerce server nor any custom fields were accessible from a search query or a search results. Obiviosly I missed a "link" with a Sitecore commerce product and the Sitecore item.

I used the "commerce server way" to build the model: when I edited a product definition I couldn't (or I don't know how) reference a field with a lookup values.

For the same purpuose I also tried the multiple choise type but I had two issues with that type:

  1. I needed to use the merchandising to put a value in, which is terrible and comes with no validations
  2. The merchandising didn't render the control as a combobox or list, instead the user must input a correct value without knowing it.

Is there a way to build a custom product model in Sitecore Commerce using the Sitecore content editor CRUD function?

5

If you want to have product property or catalog property, which will have link type (Multilist, Image, Droptree, Droplist) or any other Sitecore base types (Multi-Line Text, Rich Text) you need create your custom property in Commerce Server with Text type to add small patch to your config.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"  xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
    <commerceServer configurationProvider="Sitecore.Commerce.Connect.CommerceServer.Configuration.DefaultConfigurationProvider, Sitecore.Commerce.Connect.CommerceServer" defaultLanguage="en" defaultCurrency="USD">
      <catalogFieldTypeMapping>
        <field name="1" sitecorename="Treelist" cspropertyname="Slides" source="/sitecore/content/Storefront/Global/Carousels/Slides"/>
        <field name="2" sitecorename="Multilist" cspropertyname="Product Categories" source="/sitecore/content/Storefront/Global/Categories"/>
        <field name="3" sitecorename="Multi-Line Text" cspropertyname="ShortTextDescription"/>
        <field name="4" sitecorename="Rich Text" cspropertyname="FullTextDescription"/>
        <field name="5" sitecorename="Image" cspropertyname="ImageDescription"/>
      </catalogFieldTypeMapping>
    </commerceServer>
  </sitecore>
</configuration>

Where:

  • sitecorename - Sitecore Field Type
  • cspropertyname - Commerce Server Property Name
  • source - Path to your items for Droptree, Treelist and etc.

After add this patch you need to recycle AppPool or restart IIS and regenerate Catalog Templates. After that in Content Editor (NOT in Merchandiser Manager) you will see your mapped properties. It means, that Sitecore will map Commerce Server Text type to Sitecore Type.

In Merchandiser Manager you will see correct control only for fields which was mapped to Droplist and Image types. For all another types you need to implement custom controls, for render them in Merchandiser Manager.

I don't know why it's out of the box, better to ask Sitecore about it.

  • I did all the steps you said but in Content Editor I can't see my mapped property. I put in my patch file the following line: <field name="author-field" sitecorename="Droplist" cspropertyname="autore" source="/sitecore/content/Common/Authors"/> ; I also did a resync from commerce but in Merchandising manager I see my field as a very long textbox instead of a droplist combobox – user1624411 Jan 23 '18 at 17:10
  • 1
    try to go to Commerce tab in Content Editor and Regenerate Templates for products – Andrei Paliakou Jan 23 '18 at 17:13
  • I deleted all the data template and reloaded them. Now I can see my property in the generated template. The problem now is that Merchadising manager stopped working. It throws a null reference exception. – user1624411 Jan 23 '18 at 17:25
  • Could you add link to screenshot here? – Andrei Paliakou Jan 23 '18 at 17:28
  • Of course! prnt.sc/i4tk6f – user1624411 Jan 24 '18 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.