The below code creates the shippingGroupCommerceItemRelationship to with cItem and sg1 shipping group with quantity 1.
// remove the existing relationship between commerceItemId and shippingGroupId
getCommerceItemManager().removeItemQuantityFromShippingGroup(pOrder, pCommerceItemId, pShippingGroupId, quantity);
//Now create the new relationship
ShippingGroup sg = (ShippingGroup) order.getShippingGroup(sg1);
getCommerceItemManager().addItemQuantityToShippingGroup(order, cItem.getId(), sg.getId(), 1L);
For split shipping you can customize the code to add above logic for each each shipping group or use OOTB ShippingGroup droplet and ShippingGroupFormHandler.handleSplitShippingInfos()
Hope this help!
thanks Nooru got it
got it in removeItemQuantityFromShippingGroup() we have to pass the relationshipquantity along with CI and SG id's and order to remove the shipping information from relationship
then after to addItemQuantityToShippingGroup we have to pass the new sg id along with ci id and quantity.
instead of OOTB and customisation for splitting shippinggroup for Ci can you please share overview of code base.
You can find ATG OOTB ShippingGroupFormHandler code and related classes here C:\ATG\ATG11.2\DCS\src\Java\atg\commerce\order\purchase
Let me know if you are looking for anything specific.