As discussed above, if multiItemTypeMembershipsEnabled
is true
, the elements in siteIds
properties can include the IDs of several different item types. This can make it difficult to retrieve the IDs of an individual item type. For example, suppose the value of a product item’s siteIds
property includes siteConfiguration
, storeConfiguration
, siteGroup
, and storeGroup
IDs. If you want to retrieve just the storeConfiguration
IDs, your code would need to examine all of the siteIds
elements and determine which ones represent storeConfiguration
items.
To make looking up individual item types more efficient, the Oracle Commerce Platform includes the atg.multisite.SiteMembershipDerivation
class. You can use SiteMembershipDerivation
to compute derived properties, with each property holding the IDs of an individual context membership item type. For example, you can configure the product
item descriptor to use SiteMembershipDerivation
to create a storeIds
derived property whose value is a collection of the storeConfiguration
IDs that appear in a product’s siteIds
property.
Note that the derived property value includes only the storeConfiguration
items that explicitly appear in the siteIds
property, and does not include implicit references based on group membership. For example, if the value of siteIds
is [st:store500,stg:storeGroupUS]
, the value of the storeIds
derived property is [store500]
; it does not include the ID for each store that is a member of storeGroupUS
.
You can define a separate derived property for each site configuration item type and site group item type in the Site Repository. For example, if you have siteConfiguration
, storeConfiguration
, siteGroup
, and storeGroup
item types in the Site Repository, the definition for the product
item in the catalog repository might include:
<item-descriptor name="product"> ... <property name="webSiteIds" data-type="set" component-data-type="string" queryable="false" writable="false"> <derivation user-method="atg.multisite.SiteMembershipDerivation"></derivation> <attribute name="itemDescriptorName" value="siteConfiguration"/> </property> <property name="storeIds" data-type="set" component-data-type="string" queryable="false" writable="false"> <derivation user-method="atg.multisite.SiteMembershipDerivation"></derivation> <attribute name="itemDescriptorName" value="storeConfiguration"/> </property> <property name="siteGroupIds" data-type="set" component-data-type="string" queryable="false" writable="false"> <derivation user-method="atg.multisite.SiteMembershipDerivation"></derivation> <attribute name="itemDescriptorName" value="siteGroup"/> </property> <property name="storeGroupIds" data-type="set" component-data-type="string" queryable="false" writable="false"> <derivation user-method="atg.multisite.SiteMembershipDerivation"></derivation> <attribute name="itemDescriptorName" value="storeGroup"/> </property> ... </item-descriptor>
Note that the derived properties must be non-queryable and read-only.