Hybris 使用 CmsItemConverter 转换所有属性
Hybris convert all attributes using CmsItemConverter
我创建了一个具有这些属性的自定义组件:
自定义组件
- 字符串 ID
- 整数 sku
- 字符串颜色
- 列出变体
- 价格
变体和价格是自定义对象。
使用 DefaultCmsItemConverter OOTB 填充和转换此 CmsComponent 时:
de.hybris.platform.cmsfacades.rendering.populators.CMSComponentModelToDataRenderingPopulator#populate (line 46)
de.hybris.platform.cmsfacades.cmsitems.converter.DefaultCMSItemConverter#convert(de.hybris.platform.core.model.ItemModel)
它只填充简单的属性,如 id、sku 和颜色。 Price 和 Variants 等自定义对象不会填充到 componentData.setOtherProperties(getCmsItemConverter().convert(componentModel));
如何获得包含内部对象属性的完整填充?
步骤是:
- 为
variants
和 price
创建新的 Populator
- 将新创建的
Populator
分配给现有的Converter
查看 https://wiki.hybris.com/pages/viewpage.action?pageId=294094358 示例。
更新:以下其中一项应该适合您
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverter" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>
或
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverterCustomPopulators" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>
我创建了一个具有这些属性的自定义组件:
自定义组件
- 字符串 ID
- 整数 sku
- 字符串颜色
- 列出变体
- 价格
变体和价格是自定义对象。
使用 DefaultCmsItemConverter OOTB 填充和转换此 CmsComponent 时:
de.hybris.platform.cmsfacades.rendering.populators.CMSComponentModelToDataRenderingPopulator#populate (line 46)
de.hybris.platform.cmsfacades.cmsitems.converter.DefaultCMSItemConverter#convert(de.hybris.platform.core.model.ItemModel)
它只填充简单的属性,如 id、sku 和颜色。 Price 和 Variants 等自定义对象不会填充到 componentData.setOtherProperties(getCmsItemConverter().convert(componentModel));
如何获得包含内部对象属性的完整填充?
步骤是:
- 为
variants
和price
创建新的 - 将新创建的
Populator
分配给现有的Converter
Populator
查看 https://wiki.hybris.com/pages/viewpage.action?pageId=294094358 示例。
更新:以下其中一项应该适合您
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverter" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>
或
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverterCustomPopulators" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>