Page 1 of 1

taking control of additem workflow generates errors

Posted: Mon Feb 03, 2014 9:00 am
by Theo Schumacher
Hello,

I need to change the add item workflow of broadleaf. I'am working with 3.0.8GA.
To start, I have only copied the relevent definition in application-context.xml from core/broadleaf-framework to the site project.

So I have added to the applicationContext.xml of site/src/main/webapp/WEB-INF the following bean definitions taken from core:

Code: Select all

    <bean p:order="1000" id="blValidateAddRequestActivity" class="org.broadleafcommerce.core.order.service.workflow.add.ValidateAddRequestActivity"/>
    <bean p:order="2000" id="blAddOrderItemActivity" class="org.broadleafcommerce.core.order.service.workflow.add.AddOrderItemActivity"/>
    <bean p:order="3000" id="blAddFulfillmentGroupItemActivity" class="org.broadleafcommerce.core.order.service.workflow.add.AddFulfillmentGroupItemActivity"/>
    <bean p:order="4000" id="blAddWorkflowPriceOrderIfNecessaryActivity" class="org.broadleafcommerce.core.order.service.workflow.PriceOrderIfNecessaryActivity"/>
    <bean p:order="5000" id="blAddWorkflowVerifyFulfillmentGroupItemsActivity" class="org.broadleafcommerce.core.order.service.workflow.VerifyFulfillmentGroupItemsActivity"/>

    <bean id="blAddItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
        <property name="processContextFactory">
            <bean class="org.broadleafcommerce.core.order.service.workflow.CartOperationProcessContextFactory"/>
        </property>
        <property name="activities">
            <list>
                <ref bean="blValidateAddRequestActivity" />
                <ref bean="blAddOrderItemActivity" />
                <ref bean="blAddFulfillmentGroupItemActivity" />
                <ref bean="blAddWorkflowPriceOrderIfNecessaryActivity" />
                <ref bean="blAddWorkflowVerifyFulfillmentGroupItemsActivity" />
            </list>
        </property>
        <property name="defaultErrorHandler" ref="blDefaultErrorHandler"/>
    </bean>


starting the site works well but when i try to add a product to the cart I get:

Code: Select all

[artifact:mvn] [ERROR] 14:01:03 DefaultErrorHandler - An error occurred during the workflow
[artifact:mvn] java.lang.IllegalStateException: Not enough fulfillment group items found for DiscreteOrderItem id: 1651
[artifact:mvn]    at org.broadleafcommerce.core.order.strategy.FulfillmentGroupItemStrategyImpl.verify(FulfillmentGroupItemStrategyImpl.java:358)
[artifact:mvn]    at org.broadleafcommerce.core.order.service.workflow.VerifyFulfillmentGroupItemsActivity.execute(VerifyFulfillmentGroupItemsActivity.java:33)
[artifact:mvn]    at org.broadleafcommerce.core.order.service.workflow.VerifyFulfillmentGroupItemsActivity.execute(VerifyFulfillmentGroupItemsActivity.java:24)


Is there anything missing ?
Thx

Re: taking control of additem workflow generates errors

Posted: Wed Feb 05, 2014 11:48 am
by phillipuniverse
You should not redefine any of the Broadleaf workflows wholesale. This is a change from 2.x; workflows are now merged together. What I suspect is happening is that all of the activities are getting 'doubled-up' since what you have there is exactly how Broadleaf defines it. The final result presented to Spring will look like this:

Code: Select all

    <bean id="blAddItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
        <property name="processContextFactory">
            <bean class="org.broadleafcommerce.core.order.service.workflow.CartOperationProcessContextFactory"/>
        </property>
        <property name="activities">
            <list>
                <ref bean="blValidateAddRequestActivity" />
                <ref bean="blValidateAddRequestActivity" />
                <ref bean="blAddOrderItemActivity" />
                <ref bean="blAddOrderItemActivity" />
                <ref bean="blAddFulfillmentGroupItemActivity" />
                <ref bean="blAddFulfillmentGroupItemActivity" />
                <ref bean="blAddWorkflowPriceOrderIfNecessaryActivity" />
                <ref bean="blAddWorkflowPriceOrderIfNecessaryActivity" />
                <ref bean="blAddWorkflowVerifyFulfillmentGroupItemsActivity" />
                <ref bean="blAddWorkflowVerifyFulfillmentGroupItemsActivity" />
            </list>
        </property>
        <property name="defaultErrorHandler" ref="blDefaultErrorHandler"/>
    </bean>


Try removing your custom definition. If you need to put a new activity in this workflow, just include only your activity in the blAddItemWorkflow definition with an 'order' attribute that corresponds to where in the workflow you want your activity to go.

Re: taking control of additem workflow generates errors

Posted: Wed Feb 05, 2014 12:46 pm
by Theo Schumacher
ok, understood. Braodleaf calls correctly my new activity now with this config

Code: Select all

    <bean p:order="2500" id="AddCompuzzItemActivity" class="eu.seacloud.order.service.workflow.add.AddConfigurableBundleActivity"/>

    <bean id="blAddItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
        <property name="processContextFactory">
            <bean class="org.broadleafcommerce.core.order.service.workflow.CartOperationProcessContextFactory"/>
        </property>
        <property name="activities">
            <list>
                <ref bean="AddCompuzzItemActivity" />
            </list>
        </property>
        <property name="defaultErrorHandler" ref="blDefaultErrorHandler"/>
    </bean>
.

What I'am trying to do is to add programatically DiscreteOrderItems into a ProductBundle that is already into the cart but I can't make it work. I get always problems with the creation/sync of FulfillmentGroupItems with respect to the bundle. My Bundle is of type SeaProductBundleImpl and my Product of type SeaProductImpl, two extensions of the base Product types.

Any good idea how to do that ?

Thx