문제

I am new to ATg commerce world and was wondering if someone can help me with an issue. We have Additional properties for our CommerceItem. Once a user logs into our website, these additional properties of the commerceItem are not getting copied over. Can someone advise or give an example as to how can i make sure that the properties are copied over?

Below is a snippet of my code:

CommerceItem sourceCitem;
CommerceItem destCitem;
List citemList = pSrcOrder.getCommerceItems(); //get commerce item from source order

 for (int i = 0, citemListSize = citemList .size(); i < citemListSize; i++) {
  sourceCitem= (CommerceItem) ciList.get(i);
  destCitem= getCommerceItemManager().mergeOrdersCopyCommerceItem(pSrcOrder,pDestOrder, sourceCitem);

I extended CommerceItemImpl and added all additional properties in the new class which are not getting added to destCitem.

Any help will be appreciated.

Thanks

도움이 되었습니까?

해결책

You need to subclass CommerceItemManager and override the mergeOrdersCopyCommerceItem method to first call the superclass method to do the basic copy and then copy your extended commerce item data.

For e.g:


protected CommerceItem mergeOrdersCopyCommerceItem(Order pSrcOrder, Order pDstOrder, CommerceItem pItem) throws CommerceException {

    NewCommerceItem item = (NewCommerceItem) pItem;
    NewCommerceItem newItem = (NewCommerceItem) super.mergeOrdersCopyCommerceItem(pSrcOrder, pDstOrder, pItem);
        //Now your code to add the changes.
            newItem.setABC(item.getABC());
    return newItem;
    }

And, as the change you have already done, so it's all we need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top