【发布时间】:2020-11-29 21:00:28
【问题描述】:
我正在开发 SAP Commerce (Hybris) 1811,我正在尝试通过引用类型 ProductSales 来扩展 Product 类型,该类型将包含产品销售数据并通过 cronjob 填充.
但是,我找不到为所有新产品和现有产品初始化这种新类型的正确方法。即使在系统更新后,此引用也未初始化(空)。
Product 和 ProductSales 之间应该存在一对一的关系。
我想初始化这个引用类型:
- 在系统更新期间对所有尚无参考的现有产品进行更新
- 为所有新创建的产品创建一个实例
我的items.xml 定义:
<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>
我之所以没有将数据直接存储在Product 表中,而是作为参考,是因为我不希望在目录同步期间同步这些数据。
为所有产品初始化这种新类型的最佳方法是什么?
感谢任何提示。
【问题讨论】:
标签: hybris impex sap-commerce-cloud