Documentation

3.1.0 to 3.1.1 Migration

Remove blAdminSandboxFilter Bean

This bean is no longer necessary in 3.1.1-GA. You might see this bean in your applicationContext-admin-filter.xml within the blPostSecurityFilterChain. This can safely be removed.

Change the location of the blAdminRequestFilter

In applicationContext-filter.xml, this bean is currently in the blPreSecurityFilterChain. It should be moved to the first filter in the blPostSecurityFilterChain.

Add the blBLCJSResourceHandler to the blJsResources bean

In applicationContext-admin.xml the new blJsResources bean should be something like:

<bean id="blJsResources" class="org.broadleafcommerce.common.web.resource.BroadleafResourceHttpRequestHandler">
    <property name="handlers">
        <list>
            <ref bean="blRuleBuilderEnumOptionsResourceHandler" />
            <ref bean="blBLCJSResourceHandler" />
        </list>
    </property>
    <property name="locations" ref="blJsLocations" />
</bean>

This will resolve issues if you attempt to use BLC.servletContext() in a Javascript file and it instead returns the string //BL_SERVLET_CONTEXT rather than the actual servlet context (like admin)

Inventory Management

Basic inventory functionality has been rolled into 3.1.1-GA. The basic inventory functionality includes:

  1. A new field on BLC_SKU called QUANTITY_AVAILABLE designed to manage the inventory on the Sku
  2. New inventory types of Always Available, Unavailable and Check Availability
  3. New activities within the add to cart and update cart item workflows to check availability for a Sku, if enabled
  4. A new activity in the checkout workflow to decrement inventory

Enabling the inventory management and workflow activities is not automatic but can be added with a few simple steps:

1. Ensure that the getAvailableQuantity() and setAvailableQuantity() methods return an actual value

Out of the box these methods will always return null (indicating unset). There are a couple of ways to have them return actual values:

a. If you have already extended SkuImpl with your own implementation, add a new field to your SkuImpl subclass:

@Column(name = "QUANTITY_AVAILABLE")
@AdminPresentation(friendlyName = "SkuImpl_Sku_QuantityAvailable",
        order = 1010,
        tab = ProductImpl.Presentation.Tab.Name.Inventory,
        tabOrder = ProductImpl.Presentation.Tab.Order.Inventory,
        group = ProductImpl.Presentation.Group.Name.Inventory,
        groupOrder = ProductImpl.Presentation.Group.Order.Inventory)
protected Integer quantityAvailable = 0;

public Integer getQuantityAvailable() {
    return quantityAvailable;
}

public void setQuantityAvailable(Integer quantityAvailable) {
    this.quantityAvailable = quantityAvailable;
}

b. Configure a byte code weaver to dynamically weave in the new Sku property

Add the following XML configuration to core/src/main/resources/applicationContext.xml:

<!-- Inventory class transformer to enable simple inventory management. This transformer should be removed in Broadleaf 3.2.0+ -->
<bean id="blInventoryClassTransformer" class="org.broadleafcommerce.common.extensibility.jpa.copy.DirectCopyClassTransformer">
    <constructor-arg name="moduleName" value="Basic Inventory Management" />
    <property name="xformTemplates">
        <map>
            <entry key="org.broadleafcommerce.core.catalog.domain.SkuImpl"
                   value="org.broadleafcommerce.core.catalog.domain.QuantityAvailableSkuTemplate">
            </entry>
        </map>
    </property>
</bean>

<bean id="customClassTransformers" class="org.springframework.beans.factory.config.ListFactoryBean">
    <property name="sourceList">
        <list>
            <ref bean="blInventoryClassTransformer" />
        </list>
    </property>
</bean>

<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
    <property name="collectionRef" value="customClassTransformers" />
    <property name="targetRef" value="blMergedClassTransformers" />
</bean>

Note - this method will require you to hook up the Spring instrument jar to your application server

2. Add the CheckAvailabilityActivity to the blAddItemWorkflow and blUpdateItemWorkflow

<!-- This workflow modification is only necessary if you are managing inventory. This activity has been enabled in the core
           Broadleaf framework in version 3.2.0+ and should be removed if on that version -->
<bean id="blAddItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
    <property name="activities">
        <list>
            <bean p:order="2010" id="blCheckAddAvailabilityActivity" class="org.broadleafcommerce.core.order.service.workflow.CheckAvailabilityActivity"/>
        </list>
    </property>
</bean>

<!-- This workflow modification is only necessary if you are managing inventory. This activity has been enabled in the core
           Broadleaf framework in version 3.2.0+ and should be removed if on that version -->
<bean id="blUpdateItemWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
    <property name="activities">
        <list>
            <bean p:order="2010" id="blCheckUpdateAvailabilityActivity" class="org.broadleafcommerce.core.order.service.workflow.CheckAvailabilityActivity"/>
        </list>
    </property>
</bean>

3. Add the DecrementInventoryActivity to the blCheckoutWorkflow

<bean id="blCheckoutWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
    <property name="activities">
        <list>
            <!-- This activity is only necessary if you are managing inventory. This activity has been enabled in the core
                Broadleaf framework in version 3.2.0+ and should be removed if on that version -->
            <bean p:order="5010" id="blDecrementInventoryActivity" class="org.broadleafcommerce.core.checkout.service.workflow.DecrementInventoryActivity">
                <property name="rollbackHandler" ref="blDecrementInventoryRollbackHandler" />
            </bean>
            <!-- This activity should occur at the very end of the checkout workflow, after everything has been executed -->
            <bean p:order="9999999" class="com.mycompany.worklow.checkout.SendOrderConfirmationEmailActivity" />
        </list>
    </property>
</bean>

Now you should be able to see the 'Quantity Available' field in the admin. Once this is set to a value and the inventory type is set to 'Check Quantity', Broadleaf will now verify and update inventory when undergoing cart and checkout operations.

For a complete diff of the modifications that were made on the stock Heat Clinic demo site, see https://github.com/BroadleafCommerce/DemoSite/commit/9859c3d2b8e7d5a916d05d30e111242e23cbb3cf