Sana Connector 3.0 - Customizing Sana

When customizing Sana, often it is necessary to have slightly more information coming from ERP-System or maybe from the Add-On. The following sections will describe some extra information that can come from the Perfion AddOn that might be useful when customizing Sana.

Decorating Fields using attributes

In Sana a Field has a value. We saw how a Field could come from various sources, but it all ends up with something like this being output to Sana:

      <field name="Perfion__NoOfCups" value="4" />

The above example is taken from Table 8.

Now suppose that we have some extra information attached to that information, that this machine can brew up to 4 cups. Let us say that some machines brew bigger cups than others as suggested in below:

Figure 1: Here we have added a cup size that contains the size of the cups brewed

This information can, of course, be parsed to Sana as another field:

      <field name="Perfion__NoOfCups" value="4" />
      <field name="Perfion__CupSize" value="Medium" />

That would just work as expected.

In some cases, however, you are not after yet another field to display on the Sana-site, but rather after some customization made on the Sana-side. Therefore, you are after some way of passing the information to Sana, without creating another field.

This extra-information can be utilized on Sana for various options, which are unknown for us here at Perfion.

In the 3.0 connector, you can achieve that passing of data by passing an attribute to the field-element as shown in Table 1:

Attributes

What can be output

Supports

Supported Entities

a Features

a Attributes

a Literals

r Multi value features

a Localizable features (See note)

r Merging of features

a ProductCategory

a Product

a Variant

Sample Data

 

 

Sample Mapping

 

 

Sample output

<Response>   <Result>     <TotalCount>1</TotalCount>     <Product>       <!-- Fields from ERP and Perfion omitted here for brevity --> <field name="Perfion__NoOfCups" value="4" type="Number" size="Medium" /> <field name="Perfion__Volume" value="0.35" type="Number" unit="l" />     </Product>   </Result> </Response>

 

Table 1: Using Output Kind Attribute to decorate field-elements with extra-information.

As can be seen from Table 1, we first use Output Kind Attribute to output the value of the feature CupSize to the attribute size on the field NoOfCups. Indeed the result is that the field-element for Perfion__NoOfCups is added a size-attribute being given the value Medium.

The next example is utilizing a feature introduced in Perfion 4.5 2019 R2, namely being able to output an attribute on a feature. In the example, we output the unit-attribute from the VolumeL-feature as an attribute named unit on the Volume-Field. Indeed we get a unit containing an “l” (small letter L), which is the abbreviation for liter and is the unit for the VolumeL-feature. All attributes on Feature-elements from the Perfion API result can be output using this. See Perfion API-manual on which attributes you can output in addition to unit.

Important: The above example combines the non-localizable feature VolumeL with the localizable attribute unit. This is generally not a good idea, since you only get the unit output in the default language (here English). The best solution is to make the VolumeL-feature localizable, meaning that you need to type the same value into that feature for all languages. As a rule: All data involved should all be either localizable or not localizable. Note that that unit on a feature is localizable, whether or not the feature is it or not. Combining localizable data with non-localizable data may not give the wanted result (above you only get the English unit, not the unit in other languages). The ECommerce API-manual will give you more information on how such data is output in case you combine localizable data with a non-localizable data.

In Table 1, we have made an explicit mapping of both NoOfCups- and VolumeL-features. This is not necessary for decorating it with one or more attributes. Fields made using the wild card mapping work just as well.

Grouping information in GetEntityFields

This feature requires Connector 3.0.1 and Perfion 4.5 2019 R2

Using the Sana Standard there is no way to pass groups of fields and have Sana react on that. A field is simply a Field.

The Perfion connector, however, add some more information to this call that can be utilized when customizing Sana.

In Perfion, two constructs help group features:

  • View: A feature can be in 0 (zero) or more views. Perfion has 14 such views.

  • A feature can be in a Top View Group and/or in a View Group (and in an Information Group which cannot be sent to Sana). Perfion allows any number of groups to be created.

Sample Groups

      

 

 

 

Sample Feature

 

 

Sample output

<?xml version="1.0" encoding="utf-8"?> <Response>   <Result>     <!--EntityFields from Erp and Perfion omitted-->     ...     <Field>       <field name="Name" value="Perfion__CountryOfOrigin" />       <field name="Caption" value="Country Of Origin" />       <field name="Caption_1031" value="Ursprungsland" />       <field name="Caption_1030" value="Oprindelsesland" />       <field name="Caption_1043" value=" Land van herkomst" />       <field name="Type" value="String" />       <field name="Perfion__Views" value="Item,WebDetail,Variant" />       <field name="Perfion__GroupId" value="f99de14c-ea4c-4415-adf3-96fe03e73247" />       <field name="Perfion__GroupCaption_1030" value="Marketing" />       <field name="Perfion__GroupCaption_1031" value="Marketing" />       <field name="Perfion__GroupCaption" value="Marketing" />       <field name="Perfion__GroupCaption_1043" value="Marketing" />       <field name="Perfion__SubgroupId" value="55b92e43-ccad-46c4-9276-29971023644e" />       <field name="Perfion__SubgroupCaption_1030" value="Oprindelse" />       <field name="Perfion__SubgroupCaption_1031" value="Ursprung" />       <field name="Perfion__SubgroupCaption" value="Origin" />       <field name="Perfion__SubgroupCaption_1043" value="Oorsprong" />     </Field>     ...   <Result> <Response>

 

Table 2 shows the Feature Manufacturer, which Views it is assigned to in the configuration of Product, and which Groups it is assigned to. Finally it shows how all this is output for the feature as part of the result of a GetEntityFields-call.

GetEntityFields

Sample Views

 

 

Sample Groups

 

 

 

Sample Feature

 

 

Sample output

<?xml version="1.0" encoding="utf-8"?> <Response>   <Result>     <!--EntityFields from Erp and Perfion omitted-->     ...     <Field>       <field name="Name" value="Perfion__CountryOfOrigin" />       <field name="Caption" value="Country Of Origin" />       <field name="Caption_1031" value="Ursprungsland" />       <field name="Caption_1030" value="Oprindelsesland" />       <field name="Caption_1043" value=" Land van herkomst" />       <field name="Type" value="String" />       <field name="Perfion__Views" value="Item,WebDetail,Variant" />       <field name="Perfion__GroupId" value="f99de14c-ea4c-4415-adf3-96fe03e73247" />       <field name="Perfion__GroupCaption_1030" value="Marketing" />       <field name="Perfion__GroupCaption_1031" value="Marketing" />       <field name="Perfion__GroupCaption" value="Marketing" />       <field name="Perfion__GroupCaption_1043" value="Marketing" />       <field name="Perfion__SubgroupId" value="55b92e43-ccad-46c4-9276-29971023644e" />       <field name="Perfion__SubgroupCaption_1030" value="Oprindelse" />       <field name="Perfion__SubgroupCaption_1031" value="Ursprung" />       <field name="Perfion__SubgroupCaption" value="Origin" />       <field name="Perfion__SubgroupCaption_1043" value="Oorsprong" />     </Field>     ...   <Result> <Response>

 

Table 2: GetEntityFields-method returns information on Views and Groups from Perfion.

As can be seen in the Sample Views, we have multiple Top View Groups and View Groups. They can be considered groups and subgroups, respectively and are output as such. In addition, we see that the feature CountryOfOrigin is assigned the Top View Group Marketing and the View Group Origin. In the output we see that the field Perfion__GroupId is assigned its unique id and that we for each lcid outputs its captions in fields named  Perfion__GroupCaption. Same goes for the View Group which is called a sub group.

Note that it is possible for a feature to have a Subgroup without having a group.

The views are different.

Table 2 that the CountryOfOrigin-feature in the Products-configuration is assigned to the views Item, Variant and WebDetail. These names are fixed in Perfion and in the Sana result output exactly these names in a comma-separated list in the field Perfion__Views.

One use in Sana of these fields could be to use two views to decide whether a Field is on the list- and detail-pages, respectively. The Views WebList and WebDetail seem obvious choices for two such views, although any two views would work.

NOTE: See the ECommerce-Manual to see the exact names of all 14 available views.