我正在使用ATG 9.4并尝试修改我们的促销引擎,以便我们可以为每个促销设置过滤器属性,而不是直接在全局QualifierService上设置。
基本上,我所做的是为QualifierService上可用的每个过滤器标志添加属性到项目折扣存储库项目。然后我已经将ItemDiscountCalculator子类化并覆盖了priceItems()。我从pPricingModel读取标志,构造一个新的Qualifier对象,并将其放在带有ItemDiscountCalculator.EXTRA_PARAM_QUALIFIERSERVICE键的pExtraParameters映射中。然后我调用super.priceItems()
这完全适用于我尝试做的事情 - 然而,当我构建新的限定符时,我使用setLoggingXXX方法来反映全局QualifierService上的任何级别,但是那里有#s;没有从这些新对象中记录。
我认为这与使用核注册对象以及它使用的任何日志记录组件有关,但是我还没有找到我需要做的事情来注册它们或者至少允许Qualifier到做自然采伐。
以下是相关的代码行:
@Override
@SuppressWarnings("unchecked")
public void priceItems(List pPriceQuotes, List pItems, RepositoryItem pPricingModel, Locale pLocale, RepositoryItem pProfile, Order pOrder, Map pExtraParameters) throws PricingException {
if (isLoggingTrace())
logTrace("Entry - CustomItemDiscountCalculator.priceItems()");
Qualifier qualifierService = getQualifierService(pPricingModel);
if (pExtraParameters == null) {
pExtraParameters = new HashMap();
}
pExtraParameters.put(ItemDiscountCalculator.EXTRA_PARAM_QUALIFIERSERVICE, qualifierService);
super.priceItems(pPriceQuotes, pItems, pPricingModel, pLocale, pProfile, pOrder, pExtraParameters);
if (isLoggingTrace())
logTrace("Exit - CustomItemDiscountCalculator.priceItems()");
}
private Qualifier getQualifierService(RepositoryItem pPricingModel) {
if (isLoggingTrace())
logTrace("Entry - CustomItemDiscountCalculator.getQualifierService()");
Qualifier qualifierService = new Qualifier();
/* Get global component at /atg/commerce/pricing/QualifierService */
Qualifier defaultQualifierService = getQualifierService();
/* Shallow clone the global QualifierService component */
qualifierService.setPMDLCache(defaultQualifierService.getPMDLCache());
qualifierService.setClosenessQualifierItemDescriptorName(defaultQualifierService.getClosenessQualifierItemDescriptorName());
qualifierService.setExactlyPromotionLoopThrough(defaultQualifierService.isExactlyPromotionLoopThrough());
qualifierService.setLoggingDebug(defaultQualifierService.isLoggingDebug());
qualifierService.setLoggingError(defaultQualifierService.isLoggingError());
qualifierService.setLoggingInfo(defaultQualifierService.isLoggingInfo());
qualifierService.setLoggingTrace(defaultQualifierService.isLoggingTrace());
qualifierService.setLoggingWarning(defaultQualifierService.isLoggingWarning());
qualifierService.setNucleus(defaultQualifierService.getNucleus());
qualifierService.setPricingModelProperties(defaultQualifierService.getPricingModelProperties());
qualifierService.setPricingModelRepository(defaultQualifierService.getPricingModelRepository());
qualifierService.setServiceInfo(defaultQualifierService.getServiceInfo());
/* Set any promotion specific qualifier properties */
Boolean curFilterValue;
if (isLoggingDebug()) {
logDebug("Setting qualifier properties for promo: " + pPricingModel);
}
curFilterValue = (Boolean) pPricingModel.getPropertyValue("filterForQualifierDiscountedByAnyDiscountId");
qualifierService.setFilterForQualifierDiscountedByAnyDiscountId(curFilterValue);
// ... copy the rest of the QualifierService filters
if (isLoggingTrace())
logTrace("Exit - CustomItemDiscountCalculator.getQualifierService()");
return qualifierService;
}
答案 0 :(得分:1)
LogListener[] logListeners = defaultQualifierService.getLogListeners();
for (LogListener[] logListener : logListeners) {
qualifierService.addLogListener(logListener);
}