Page 1 of 1

Admin Metadata Overrides Questions for fulfillmentFlatRates

Posted: Sat Sep 13, 2014 6:24 am
by daniel_locious
Hi guys,

I am trying to add SkuImpl.fulfillmentFlatRates into Admin Presentation layer, so that I can edit the value on admin tools. I followed the instruction of Admin Metadata Overrides, and was trying to use xml-based overrides, but not working.

My questions are:

First, I suspect the override doesn't work is because the field has no @AdminPresentation or @AdminPresentationMap annotation announced. How could I add annotation onto this field without change SkuImpl? I tried to re-inject another SkuExtImpl class to the site and admin, but it doesn't work; the ProductImpl only looks for SkuImpl.

Here is my dependency injection configuration:
in core/src/main/resources/applicationContext-entity.xml
<bean id="org.broadleafcommerce.core.catalog.domain.Sku" class="com.mycompany.broadleaf.ext.domain.SkuExtImpl" scope="prototype"/>
in persistence-core.xml
<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/web</non-jta-data-source>
<class>com.mycompany.broadleaf.ext.domain.SkuExtImpl</class>
.....

I don't understand why the ProductImpl is still looking for SkuImpl. By the way there is a typo in "Extending Entities Tutorial"
"<bean id="org.broadleafcommerce.core.catalog.domain.Product" class="com.mycompany.core.catalog.domain.HotSauceImpl" scope="prototye"/>" should be "prototype".

Secondly, I believe the fulfillmentFlatRates mapping the FulfillmentOptions which should include a filter like "UseFlatRates=true"; how to add this filter on hibernate annotation? or any other annotations?

Finally I attached my xml-based override configuration

<!-- Admin Edit MetaData Overrides -->
<mo:override id="blMetadataOverrides">
<mo:overrideItem ceilingEntity="org.broadleafcommerce.core.catalog.domain.Sku">
<mo:field name="fulfillmentFlatRates">
<mo:property name="group" value="ProductWeight_Shipping" />
<mo:property name="tab" value="ProductImpl_Shipping_Tab" />
<mo:property name="tabOrder" value="6000" />
<mo:property name="groupOrder" value="1000" />
<mo:property name="order" value="10000" />
<mo:property name="friendlyName" value="SkuImpl_FulfillmentFlatRates" />
</mo:field>
</mo:overrideItem>
</mo:override>

Would you please advise where did i do incorrect? I was blocked here for a while.

Regards,

Dan

Re: Admin Metadata Overrides Questions for fulfillmentFlatRates

Posted: Sat Sep 13, 2014 2:25 pm
by phillipuniverse
First, I suspect the override doesn't work is because the field has no @AdminPresentation or @AdminPresentationMap annotation announced. How could I add annotation onto this field without change SkuImpl?


Yeah you are right and I consider this is a bug in the system. Can you please open an issue at https://github.com/BroadleafCommerce/Br ... rce/issues? I don't think this will be that difficult and you should be able to display fields in the admin that you want even if we haven't annotated them (although in this specific case we probably should be exposing this functionality in the admin anyway).

I don't understand why the ProductImpl is still looking for SkuImpl


If you have added the override to applicationContext-entity.xml then this should not be happening. As a sanity check, ensure that the admin application is getting the latest version of the core jar (as in, re-do a maven install from the root)?

Secondly, I believe the fulfillmentFlatRates mapping the FulfillmentOptions which should include a filter like "UseFlatRates=true"; how to add this filter on hibernate annotation? or any other annotations?


You might be right here; I am not 100% on what the right way to do that is. It almost seems like an admin concern. Could you open an issue at https://github.com/BroadleafCommerce/Br ... rce/issues to track it?

Re: Admin Metadata Overrides Questions for fulfillmentFlatRates

Posted: Mon Sep 15, 2014 4:16 am
by daniel_locious
Yeah you are right and I consider this is a bug in the system. Can you please open an issue at https://github.com/BroadleafCommerce/Br ... rce/issues? I don't think this will be that difficult and you should be able to display fields in the admin that you want even if we haven't annotated them (although in this specific case we probably should be exposing this functionality in the admin anyway).


Have created the issue #1122

Could you explain a bit more on the details of "display fields in the admin that you want even if we haven't annotated them"? I checked the code; in my understanding the fields (and even the form) of the page are all dynamically generated based on the annotations. I doubt which admin template that I could modify in this case - saying that I would put this fulfillmentFlatRates field beside other shipping fields in the tab.

If you have added the override to applicationContext-entity.xml then this should not be happening. As a sanity check, ensure that the admin application is getting the latest version of the core jar (as in, re-do a maven install from the root)?


Did recompiled but no difference; actually in the productImpl class ProductImpl.defaultSku is targetting to SkuImpl.... don't know if this is the reason that I can't override the class? (doesn't make sense? I am really confused, so...)