I'm working on SAP Commerce (Hybris) 1811 and I'm trying to extend a Product
type with a reference to a type ProductSales
, which is going to contain product sales data and be filled via a cronjob.
However, I can't find a proper way to initialize this new type for all new and existing products. Even after a system update, this reference is uninitialized (null).
There should be a 1-to-1 relation between Product
and ProductSales
.
I'd like this referenced type to be initialized:
My items.xml
definition:
<itemtype code="ProductSales" autocreate="true" generate="true" >
<deployment table="productsales" typecode="15011" />
<attributes>
<attribute qualifier="unitsSold" type="localized:java.lang.Long">
<description>Amount of units sold</description>
<persistence type="property"/>
</attribute>
<attribute qualifier="ordersCount" type="localized:java.lang.Long">
<description>Count of how many orders contained this product</description>
<persistence type="property"/>
</attribute>
</attributes>
</itemtype>
<itemtype code="Product" autocreate="false" generate="false">
...
<attribute qualifier="productSales" type="ProductSales">
<description>Product Sales</description>
<modifiers partof="true" optional="false" initial="true" />
<persistence type="property"/>
</attribute>
...
</itemtype>
The reason I'm not storing the data directly in the Product
table, but as a reference, is that I don't want these data to be synchronized during catalog synchronization.
What would be the best way to initialize this new type for all products?
Thanks for any tips.
In the end, I solved this by creating the missing references in the cronjob itself. I only create this wrapper object in the staged catalog to be synced later.
By the way, I found that besides modifying the sync job, creating a wrapper object and keeping its reference synchronized between the catalogs is the solution recommended by SAP.