Page 1 of 1

facet on custom entity

Posted: Wed Jan 16, 2013 11:34 am
by pluto
Hey,

I'm extending the product entity and I want to use a facet on a specific "new" field. How can I do that?
I suppose I need to add a row in blc_field but I don't now what to put in entity_type and property_name.

Greets and thanks,

Pluto

Re: facet on custom entity

Posted: Wed Jan 23, 2013 10:38 am
by phillipuniverse
We have some documentation around this at http://docs.broadleafcommerce.org/2.2/C ... earch.html. Let us know if you still have questions after looking at the docs.

Re: facet on custom entity

Posted: Sat Feb 23, 2013 2:45 am
by pluto
Hey Philipuniverse,

I' m sorry for the late reply.

I understand the documentation but I can't find the solution for my problem.

When I use attributes I can simply create a filter when I create a blc_field in the database with entity_type PRODUCT and property_name productAttributes.attri1
But now I want to extend Product with an extra field attri1. So how can I do the filtering on that?
Will the entity type stays PRODUCT do I need the use the name of the new entity?
How to name the property_name?
I tried a few combinations but can't figure it out.
Or do I need to change something else?

Thanks!

Pluto

Re: facet on custom entity

Posted: Sat Feb 23, 2013 5:49 pm
by phillipuniverse
If you have actually extended Product are you are adding fields to your extended entity (not just using them via the ProductAttributes list) then the field name is whatever field you added to Product. So if you did this:

Code: Select all

public class CustomProduct extends ProductImpl {

   @
Column(name="NEW_PROPERTY");
    protected 
String someNewProperty;
}
 


and then you wanted a facet on that field, you would add a row in blc_field with the entity_type of 'PRODUCT' and a property_name of 'someNewProperty'. The field name is always the field name as it relates to the Product entity (which is why you can add a field for defaultSku.retailPrice).

However, setting up a BLC_FIELD is only half of the equation if you actually want it to be facetable. You will also need to make an entry into either BLC_SEARCH_FACET (SearchFacet class, used for global facets for all categories) or BLC_CATEGORY_SEARCH_FACET (CategorySearchFacet class, used for facets displayed in a specific category).

Re: facet on custom entity

Posted: Sun Mar 03, 2013 4:40 am
by pluto
phillipuniverse you 're my hero! Thanks

Re: facet on custom entity

Posted: Fri Apr 19, 2013 3:04 pm
by mota_nginya
What if I want to show categories rather than prices. That is I want to see my default categories and the number of items that are linked to them. How do I go about changing the view to get that done? I have already taken care of the database by adding a new record in there.

Thanks!

Re: facet on custom entity

Posted: Mon Jul 01, 2013 5:11 am
by janschraepen
@pluto

Did you actually get a working filter on productAttributes? How did you achieve this?

I'm trying to do such a thing, and have added a record to the BLC_FIELD table with ENTITY_TYPE = PRODUCT and PROPERTY_NAME = productAttribute.attri1. Am I correct when assuming that attri1 is the key of the attribute I'm trying to query?
I also had to add a record to the BLC_FIELD_SEARCH_TYPES table having a reference to my newly created record in BLC_FIELD and with a SEARCHABLE_FIELD_TYPE 't'
Finally, in order to make the field facetable, I created a global search facet record in BLC_SEARCH_FACET. The above steps however didn't have an effect. Searching on a value of an attribute did not work..

Do you have any ideas/hints to help me further?
Thx in advance!

Jan

pluto wrote:Hey Philipuniverse,

I' m sorry for the late reply.

I understand the documentation but I can't find the solution for my problem.

When I use attributes I can simply create a filter when I create a blc_field in the database with entity_type PRODUCT and property_name productAttributes.attri1
But now I want to extend Product with an extra field attri1. So how can I do the filtering on that?
Will the entity type stays PRODUCT do I need the use the name of the new entity?
How to name the property_name?
I tried a few combinations but can't figure it out.
Or do I need to change something else?

Thanks!

Pluto

Re: facet on custom entity

Posted: Fri Jun 19, 2015 6:45 am
by labedzkim
phillipuniverse wrote:and then you wanted a facet on that field, you would add a row in blc_field with the entity_type of 'PRODUCT' and a property_name of 'someNewProperty'. The field name is always the field name as it relates to the Product entity (which is why you can add a field for defaultSku.retailPrice).


Hi All,
let me extend the above reply. When you define such a new field then you probably get errors like 'property someNewProperty not found' for those products that are instances of class ProductImpl. To avoid such errors you need to remove all products of type ProductImpl and leave only products of the new type CustomProduct. There is no possibility to have a mix of both types (ProductImpl and CustomProduct) because fieldDao accepts fields defined only for a Product entity. Any attempt of defining field on CustomProduct entity will not take effect because fieldDao fiters it out and thereby such a field will no be indexed.

Regards,
Maciej

Re: facet on custom entity

Posted: Sun Jun 21, 2015 8:25 pm
by phillipuniverse
@Maciej thanks for the clarification!