Hybris 如何从local.properties获取配置数据到impex?

Hybris 如何从local.properties获取配置数据到impex?,hybris,impex,Hybris,Impex,是否可以从local.properties配置文件中定义的环境变量中获取值,并通过impex文件访问该值 前 $someMacro= 谢谢大家! 您可以将此添加到impex中: # Import config properties into impex macros UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[uniqu

是否可以从local.properties配置文件中定义的环境变量中获取值,并通过impex文件访问该值

$someMacro=

谢谢大家!

您可以将此添加到impex中:

# Import config properties into impex macros
UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]
现在已加载local.properties等中的所有配置,并可通过
$config-
前缀使用,例如:

local.properties

your.config.property=322
所以你的弹劾案看起来像:

# Import config properties into impex macros
UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]

$variable=$config-your.config.property

INSERT_UPDATE SampleItem;code[unique=true];name
;sample1;$variable

# OR you can just directly use the config macro
INSERT_UPDATE SampleItem;code[unique=true];name
;sample1;$config-your.config.property
希望这对你有用

编辑:还请注意,如果未找到此类属性,则存储在上述示例上的值应为:
$config your.config.property

要完成此操作,可以避免仅使用标题行

这条线只是为了加载属性,这太难看了。。。但这实际上是
ConfigPropertyImportProcessor
类注释中提到的:

  /**
   * Impex ImportProcessor that injects all config properties as impex definitions.
   * All defined configuration properties are added as impex macro definitions with
   * the prefix of "config-". For example the config key <tt>mail.smtp.server</tt>
   * can be accessed via the macro <tt>$config-mail.smtp.server</tt>.
   * In order to use this import processor and to load the configuration properties
   * the following must be added to the top of the impex file:
   *
   * <tt>UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]</tt>
   */

但是您需要启用代码执行。

很好!谢谢
  /**
   * Impex ImportProcessor that injects all config properties as impex definitions.
   * All defined configuration properties are added as impex macro definitions with
   * the prefix of "config-". For example the config key <tt>mail.smtp.server</tt>
   * can be accessed via the macro <tt>$config-mail.smtp.server</tt>.
   * In order to use this import processor and to load the configuration properties
   * the following must be added to the top of the impex file:
   *
   * <tt>UPDATE GenericItem[processor=de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor];pk[unique=true]</tt>
   */
#%new de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor().init(impex)