Page 1 of 1

How to override ProductImpl?

Posted: Sat Jun 14, 2014 5:11 am
by gowthamgutha
I would want to entirely replace ProductImpl with my own implementation so that there is no ProductImpl in my site at all!. I no longer want to associate the table BLC_PRODUCT with the ProductImpl class provided by the Broadleaf commerce. Rather, I would like to write a new class which is associated with the BLC_PRODUCT table only (i.e. I don't want to change the table name).

I wrote a class that directly implements interfaces that are implemented by the ProductImpl class. My class looks pretty much similar to the ProductImpl with two additional fields.

Now, how would I project it as an alternative to the default ProductImpl class and make sure that ProductImpl class is no longer accessed in my Broadleaf site.

I've gone through the Broadleaf documentation and have not found an answer for my question.

Hope it is clear.
Thanks in advance.

Re: How to override ProductImpl?

Posted: Sat Jun 14, 2014 11:47 am
by phillipuniverse
If you are still using the BLC_PRODUCT table with all of the fields from ProductImpl, I am still questioning why you don't just do something like single-table inheritance: http://www.broadleafcommerce.com/docs/c ... s-tutorial (scroll down to the 'Single table inheritance' section). This will only have the single BLC_PRODUCT table with an extra discriminator column to denote which type it is (ProductImpl or your own).

Nevertheless, to do what you are asking I believe you would have to filter out the ProductImpl class listing from the framework persistence.xml: https://github.com/BroadleafCommerce/Br ... mework.xml. I'm not sure if this is something that we support, but I can see value for it outside of the specific use case that you have where others want to exclude entities from Broadleaf that they are not using in their implementation.

I think that warrants an issue on https://github.com/BroadleafCommerce/Br ... rce/issues if you would like to create it.