Hybris自定义电子邮件设置自定义属性

时间:2018-09-11 12:24:08

标签: java email hybris

我正在创建自定义电子邮件,应在填写约会表格后将其发送给客户。我需要其他属性,所以我扩展了AbstractEmailContext

public class AppointmentEmailContext extends AbstractEmailContext
{
   private String myAttribute;
   ...
}

在开始该过程之前,我先在EventListener中设置属性:

final AppointmentProcessModel storeFrontCustomerProcessModel = (AppointmentProcessModel) getBusinessProcessService()
                .createProcess(
                        "appointmentEmailProcess-" + event.getEmail() + "-" + System.currentTimeMillis(),
                        "appointmentEmailProcess");

storeFrontCustomerProcessModel.setMyAttribute("test@test.com");
getModelService().save(storeFrontCustomerProcessModel);
getBusinessProcessService().startProcess(storeFrontCustomerProcessModel);

init的{​​{1}}方法中,我无法获取这些参数,因此可以正确设置它们并将它们传递给电子邮件模板。另一件事是,在AppointmentEmailContext方法中输入的ProcessModel不是init的实例,而是AppointmentProcessModel的实例,即使我的StoreFrontCustomerProcessModel对其进行了扩展。 / p>

我还试图这样添加AppointmentProcessModel

AppointmentProcessModel

并使用正确的参数调整init方法(+添加覆盖方法),但是在创建过程时出现错误:

public class AppointmentEmailContext extends AbstractEmailContext<AppointmentProcessModel>
{
...
}

我不知道这些属性的持久化是否存在问题,还是应该以其他方式传递这些属性。

更新: 我尝试将ERROR [hybrisHTTP21] [HybrisApplicationEventMulticaster] java.lang.InstantiationException: mypackage.core.appointment.model.AppointmentProcessModel java.lang.RuntimeException: java.lang.InstantiationException: mypackage.core.appointment.model.AppointmentProcessModel 添加到AppointmentProcess文件中,并且进行了系统更新,但没有任何更改。我在后台办公室中检查了是否添加了类型,并且该类型是从*-items.xml扩展的。定义如下:

StoreFrontCustomerProcess

1 个答案:

答案 0 :(得分:1)

通过HMC交叉验证是否将您的属性保存在storeFrontCustomerProcessModel中?

尝试更改类似的 AppointmentEmailContext

public class AppointmentEmailContext extends AbstractEmailContext<AppointmentProcessModel>
{
   private String myAttribute;

    @Override
    public void init(final AppointmentProcessModel appointmentProcessModel, final EmailPageModel emailPageModel)
    {
        super.init(appointmentProcessModel, emailPageModel);
        myAttribute = appointmentProcessModel.getMyAttribute();
    }

    public String getMyAttribute() {
        return myAttribute;
    }

    //...
}

修改

用户尚未为AppointmentProcess创建商品类型,后来他按照我在评论中提到的方式创建了商品,问题已解决!