First step is to do probably what you've already done, and subclass OrderStatus and add your new types:
Code: Select all
package com.mycompany.order.service.type
public class CustomOrderStatus extends OrderStatus {
private static final long serialVersionUID = 1L;
public static final OrderStatus CANCELLED = new OrderStatus("CANCELLED", "Cancelled");
}
If you already have a subclass of OrderImpl (perhaps MyCompanyOrderImpl) then you can just add in an @AdminPresentationOverride (works for 1.x and 2.x versions of BLC):
Code: Select all
@AdminPresentationOverrides({
@AdminPresentationOverride(name="status", value=@AdminPresentation(friendlyName = "Order Status", group = "Order", order=2, prominent=true, fieldType=SupportedFieldType.BROADLEAF_ENUMERATION, broadleafEnumeration="com.mycompany.order.service.type.CustomOrderStatus"))
});
public class MyCompanyOrderImpl extends OrderImpl {
...whatever custom code you have
}
If you
don't already have a subclass of Order and thus can't do the override this way, if you're on 2.0 or higher (highly recommended btw) then you can achieve this via XML. So in your applicationContext-admin.xml you would have this:
Code: Select all
<mo:override id="blMetadataOverrides">
<mo:overrideItem ceilingEntity="org.broadleafcommerce.core.order.domain.Order">
<mo:field name="status">
<mo:property name="broadleafEnumeration" value="com.mycompany.order.service.type.CustomOrderStatus" />
</mo:field>
</mo:overrideItem>
</mo:override>
In order to get the XML markup to validate correctly, you will also need to include the 'mo' xsd in your schemaLocations and define the mo: namespace. This is what you have to have in you <beans> root element (along with all of your other namespaces and schemaLocations that are already there):
Code: Select all
<beans xmlns="xmlns:mo="http://schema.broadleafcommerce.org/mo"
xsi:schemaLocation="http://schema.broadleafcommerce.org/mo
http://schema.broadleafcommerce.org/mo/mo-2.0.xsd">
So a complete <beans> element from applicationContext-admin.xml might look like this:
Code: Select all
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mo="http://schema.broadleafcommerce.org/mo"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://schema.broadleafcommerce.org/mo
http://schema.broadleafcommerce.org/mo/mo-2.0.xsd">
And just a note, the XML and annotation versions that I mentioned are equivalent.