Page 1 of 1

how to remove new product type option?

Posted: Sun Mar 08, 2015 12:52 am
by prabhat.kataria
I have extended ProductImpl class to have more fields related to a product and I have 2 questions around it.

In admin login when I go for adding a new product I get following options:
Product
Custom Product
Product Bundle

How can I permanently remove new product option named "Product" so that admin sees only two new product option namely "CustomProduct" and "Product Bundle".

Also, If I want to remove some new product option for a subset of users how can I proceed for it?

Re: how to remove new product type option?

Posted: Mon Mar 23, 2015 11:14 pm
by phillipuniverse
Your first question is to annotate your Custom Product with @AdminpresentationClass.

Your second question I need more information on to properly respond.

Re: how to remove new product type option?

Posted: Sat Mar 28, 2015 6:39 am
by prabhat.kataria
Hi Phillip,

1. I tried using @AdminpresentationClass as below but I am still able to see the "Product" option. Am I doing something wrong?

Code: Select all

@AdminPresentationClass(populateToOneFields = PopulateToOneFieldsEnum.TRUE,
                  friendlyName = "Custom Product",
                  ceilingDisplayEntity = "org.broadleafcommerce.core.catalog.domain.ProductImpl")


2. By me second question what I meant to say is I have 10 admin users and there are 2 implementation of Product interface i.e "Product", "Custom Product". Now I want only 5 of the admin users should be able to see "Product" option for adding a product while the other 5 should see "Custom Product". Is it possible?

Re: how to remove new product type option?

Posted: Mon Mar 30, 2015 11:56 pm
by phillipuniverse
1. I tried using @AdminpresentationClass as below but I am still able to see the "Product" option. Am I doing something wrong?


Yes, the ceilingDisplayEntity should be your custom type.

2. By me second question what I meant to say is I have 10 admin users and there are 2 implementation of Product interface i.e "Product", "Custom Product". Now I want only 5 of the admin users should be able to see "Product" option for adding a product while the other 5 should see "Custom Product". Is it possible?


It is, you will have to modify a different section of the code. The polymorphic types that are computed are done so in DynamicEntityDaoImpl. If you want to customize this list (by checking the admin user and changing the results) you will need to subclass DynamicEntityDaoImpl, override the blDynamicEntityDao bean (and ensure the scope property is set to "prototype") and override the getClassTreeFromCeiling() method. From there you can remove spots in the tree that you don't want based on the admin user that is currently logged in.

Re: how to remove new product type option?

Posted: Sun Jun 21, 2015 1:55 am
by prabhat.kataria
Thank you Philip for the answer. Solution to the point 1 works perfect but will still need some time and analysis around point 2. ;)