Hybris 中的 Translator vs Cell Decorator,在什么情况下首选哪个
Translator vs Cell Decorator in hybris, which one is preferred in what situation
我知道如何在 impex imports
期间编写和使用 Cell Decorator
和 Translators
在 hybris 中,但是,我不确定哪个优先于另一个?
例如,我使用 Cell Decorator 稍微更改了一个属性的值,如果客户来自美国,我将在插入数据库时在客户编号末尾附加一个“_US”。
同样,当我需要根据产品 ID 查找库存产品 Available/Out 的状态时,我使用了 Translator。
但是,我不是 100% 肯定这是唯一的区别。
任何带有示例的解释将不胜感激。
什么是翻译器?
A translator class is a converter between ImpEx-related CSV files and values of attributes of Hybris Commerce items
翻译器是一个“转换器”,当您需要将数据修改为其他类型的数据时使用它。
什么是装饰器?
(来自 Wikipedia)
The decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
hybris 中应该使用什么
对于 Impex,大多数时候你想使用 translator,因为你想在 Impex 文件中使用简单的语法和 convert (即 translate/modify)使用代码将其转换为目标格式。
当您需要向现有功能添加功能时,请使用 装饰器。如果你想添加数据,它也可以用在Impex中。
例如你可以阅读装饰器的维基百科文章,在 hybris 中你可以查看 ChineseLogisticCellDecorator
。对于翻译人员,您在 hybris 文档中有列表(如上所述)
我知道如何在 impex imports
Cell Decorator
和 Translators
在 hybris 中,但是,我不确定哪个优先于另一个?
例如,我使用 Cell Decorator 稍微更改了一个属性的值,如果客户来自美国,我将在插入数据库时在客户编号末尾附加一个“_US”。 同样,当我需要根据产品 ID 查找库存产品 Available/Out 的状态时,我使用了 Translator。
但是,我不是 100% 肯定这是唯一的区别。
任何带有示例的解释将不胜感激。
什么是翻译器?
A translator class is a converter between ImpEx-related CSV files and values of attributes of Hybris Commerce items
翻译器是一个“转换器”,当您需要将数据修改为其他类型的数据时使用它。
什么是装饰器?
(来自 Wikipedia)
The decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
hybris 中应该使用什么
对于 Impex,大多数时候你想使用 translator,因为你想在 Impex 文件中使用简单的语法和 convert (即 translate/modify)使用代码将其转换为目标格式。
当您需要向现有功能添加功能时,请使用 装饰器。如果你想添加数据,它也可以用在Impex中。
例如你可以阅读装饰器的维基百科文章,在 hybris 中你可以查看 ChineseLogisticCellDecorator
。对于翻译人员,您在 hybris 文档中有列表(如上所述)