Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-5570

appendOrderItem Service Not Applying Order Item Attributes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: 14.12.01, 13.07.02, 16.11.01
    • Component/s: order
    • Labels:
      None
    • Sprint:
      Bug Crush Event - 21/2/2015

      Description

      Please see the user mailing list discussion: http://ofbiz.135035.n4.nabble.com/Possible-Issue-appendOrderItem-Service-td4648984.html

      Copied issue for archival purposes:

      Hi Folks,

      I'm running 12.04.02,

      I'm using the "appendOrderItem" service in the order application. The service definition allows for an optional Map of order item attributes called "itemAttributesMap". However, the addItemToApprovedOrder method in OrderServices isn't using that map from the service context, thus the order item attributes aren't being added to the item when it's added to the order.

      I've checked the addItemToApprovedOrder method in the trunk OrderServices, and the itemAttributesMap is not being utilized there either. I can fix and submit a patch (see implementation in updateOrderItems service), but wanted to ensure this wasn't a design choice.

      Thanks,
      Darrell

        Activity

        Hide
        pfm.smits Pierre Smits added a comment -

        Darrel,

        Could you elaborate on what you think should be going into that map? Is it attributes related to the product, or other attributes related to the order item (which, depending on the type of order - e.g. sales/service/etc), can differ from product attributes)?

        Could you share some expamples to help me, and others, understand...

        Regards,

        Pierre

        Show
        pfm.smits Pierre Smits added a comment - Darrel, Could you elaborate on what you think should be going into that map? Is it attributes related to the product, or other attributes related to the order item (which, depending on the type of order - e.g. sales/service/etc), can differ from product attributes)? Could you share some expamples to help me, and others, understand... Regards, Pierre
        Hide
        darrell73s Darrell Donati added a comment -

        Hi Pierre,

        It's possible that my interpretation of the use of the itemAttributesMap field is incorrect, but given its usage in the updateOrderItems service is how I came to the conclusion that it should be used for OrderItemAttribute's. Note that in updateOrderItems, the usage appears slightly different in that the service is updating multiple items in a single order, so the map takes in a combined key (orderItemSeqId, and orderItemAttrKey delimited by colon) in order to allow a single map to be used for many items.

        What I'm thinking should go in the "itemAttributesMap" is a Map<String,String> of entries which will ultimately end up in the OrderItemAttribute entity.

        The service currently gets a handle to a cart representing the order, adds in the new product, and then calls saveUpdatedCartToOrder(). This method calls cart.makeAllOrderItemAttributes(), which would get the GenericValues representing the "OrderItemAttribute" entity for all items in the cart. However, since these OrderItemAttributes aren't being set on the item as it's added into the cart in the 'addItemToApprovedOrder' service, the makeAllOrderItemAttributes() call is empty.

        For example, given a SALES Order with orderId 10000, I run the "addItemToApprovedOrder" service, passing in the requisite fields, and itemAttributesMap with value ["FOO":"BAR"]. If you query the OrderItemAttribute entity, I would expect to see: [orderId: 10000, attrName: FOO, attrValue: BAR].

        Thanks,
        Darrell

        Show
        darrell73s Darrell Donati added a comment - Hi Pierre, It's possible that my interpretation of the use of the itemAttributesMap field is incorrect, but given its usage in the updateOrderItems service is how I came to the conclusion that it should be used for OrderItemAttribute's. Note that in updateOrderItems, the usage appears slightly different in that the service is updating multiple items in a single order, so the map takes in a combined key (orderItemSeqId, and orderItemAttrKey delimited by colon) in order to allow a single map to be used for many items. What I'm thinking should go in the "itemAttributesMap" is a Map<String,String> of entries which will ultimately end up in the OrderItemAttribute entity. The service currently gets a handle to a cart representing the order, adds in the new product, and then calls saveUpdatedCartToOrder(). This method calls cart.makeAllOrderItemAttributes(), which would get the GenericValues representing the "OrderItemAttribute" entity for all items in the cart. However, since these OrderItemAttributes aren't being set on the item as it's added into the cart in the 'addItemToApprovedOrder' service, the makeAllOrderItemAttributes() call is empty. For example, given a SALES Order with orderId 10000, I run the "addItemToApprovedOrder" service, passing in the requisite fields, and itemAttributesMap with value ["FOO":"BAR"] . If you query the OrderItemAttribute entity, I would expect to see: [orderId: 10000, attrName: FOO, attrValue: BAR] . Thanks, Darrell
        Hide
        diveshdut Divesh Dutta added a comment -

        Hi Darrell,

        This was not design choice to not to process itemAttributesMap. We can definitely add code to process itemAttributesMap and code can be similar to code written in updateApprovedOrderItems method of OrderServices.java

        Show
        diveshdut Divesh Dutta added a comment - Hi Darrell, This was not design choice to not to process itemAttributesMap. We can definitely add code to process itemAttributesMap and code can be similar to code written in updateApprovedOrderItems method of OrderServices.java
        Hide
        diveshdut Divesh Dutta added a comment -

        Here is the patch to process itemAttributesMap in addItemToApprovedOrder service implementation.

        Show
        diveshdut Divesh Dutta added a comment - Here is the patch to process itemAttributesMap in addItemToApprovedOrder service implementation.
        Hide
        toashishvijay Ashish Vijaywargiya added a comment -

        Thanks Darrell Danoti for creating the issue, thanks Divesh for providing the patch.

        Changes are committed on the following revisions:

        trunk - r1661316
        R14.12 - r1661317
        R13.07 - r1661318

        Show
        toashishvijay Ashish Vijaywargiya added a comment - Thanks Darrell Danoti for creating the issue, thanks Divesh for providing the patch. Changes are committed on the following revisions: trunk - r1661316 R14.12 - r1661317 R13.07 - r1661318

          People

          • Assignee:
            toashishvijay Ashish Vijaywargiya
            Reporter:
            darrell73s Darrell Donati
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development

                Agile