Page 1 of 1

mo:override, overriding enumeration types

Posted: Tue Jun 18, 2013 4:05 pm
by jasoneasterday
I was trying to override a enumeration type and didn't find much information on it. Once Phillip pointed me in the right direction, i wanted to put this out there incase anyone else need help on it.

Scenario, add a new value to the Inventory Type in the admin screen for a Product.
to do: Create a new class in the admin: org.broadleafcommerce.core.order.service.type.MyInventoryType

Code: Select all

public class MyInventoryType extends InventoryType {

   private static final long serialVersionUID = 1L;

    public static final InventoryType NONE = new InventoryType("PREORDER", "Pre-Publication");
   
}

Next reference it using mo:overrides
in the top of the xml of applicationContext-admin.xml, verify or add

Code: Select all

xmlns:mo="http://schema.broadleafcommerce.org/mo"

then append to xsi:schemaLocation

Code: Select all

http://schema.broadleafcommerce.org/mo
http://schema.broadleafcommerce.org/mo/mo-2.2.xsd

next, add the mo:override tag and configuration

Code: Select all

<mo:override id="blMetadataOverrides">
      <mo:overrideItem ceilingEntity="org.broadleafcommerce.core.catalog.domain.Product">
         <mo:field name="defaultSku.inventoryType">
            <mo:property name="broadleafEnumeration" value="org.broadleafcommerce.core.order.service.type.MyInventoryType" />
         </mo:field>
      </mo:overrideItem>
   </mo:override>

explanation:
the ceilingEntity is ultimately the entity that the information is located at.
field name is the field you are wanting to add to from the ceiling entity point of view.
property is enumeration type, and the value being the class that you just created.
build and start it up.

Re: mo:override, overriding enumeration types

Posted: Fri Jan 03, 2014 9:25 am
by sattymish
Hi Jason,
I am trying to make the status field of an order editable. Below are the changes I made in applicationContext-admin.xml but this didn't help.

Code: Select all

        <beans
        xmlns:mo="http://schema.broadleafcommerce.org/mo"
   xsi:schemaLocation="....
                                        .....
                                          http://schema.broadleafcommerce.org/mo
                                          http://schema.broadleafcommerce.org/mo/mo-3.0.xsd">


   <mo:override id="blMetadataOverrides">
      <mo:overrideItem ceilingEntity="org.broadleafcommerce.core.order.domain.OrderImpl">
         <mo:field name="status">
            <mo:property name="readOnly" value="false" />
         </mo:field>
      </mo:overrideItem>
   </mo:override>



Appreciate the help and support.

Thanks,
Satyam

Re: mo:override, overriding enumeration types

Posted: Tue Jan 07, 2014 3:44 pm
by phillipuniverse
Rather than using OrderImpl for the ceiling entity, try using the interface: org.broadleafcommerce.core.domain.Order.

Re: mo:override, overriding enumeration types

Posted: Tue Jan 07, 2014 3:45 pm
by phillipuniverse
By the way, there is a bug associated with this in that in some cases you need to use the concrete entity (OrderImpl) and in others you need to use the interface (Order). See https://github.com/BroadleafCommerce/Br ... issues/138