cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Flexible search a custom parameter?

Former Member
0 Likes
1,521

We have added new columns to the table underlying the PaymentInfo object (in PAYMENTINFOS)

To get hold of these values in Java we use the paymentInfo.getAttribute("COLUMN_NAME") function.

Question is though, how do you go about accessing these columns using flexsearch?

Obviously you cant do it like

SELECT {o.pk} FROM {Order as o JOIN PaymentInfo AS p ON {o.paymentInfo} = {p.pk}} WHERE {o.paymentMode} in ('12345') AND {o.store} IN ('9999') AND ({p.p_bankidnumber} IS NOT NULL OR {p.p_accountnumber} IS NOT NULL)

because p_bankidnumber and p_accountnumber are not part of the PaymentInfo object that comes with the Hybris platform.

So maybe there must be a way to mimic the getAttribute function I mentioned above?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Likes

Thanks a lot guys, much appreciated. The problem was really my lack of understanding how the type hierarchy was done in Hybris. But I'm now able to locate the right type extending PaymentInfo by which to address those custom table columns.

0 Likes

As per previous answers, extension of the Hybris type system (in the correct manner) is key to a successful Hybris project. Have a look at the online help for an introduction into the type system https://help.hybris.com/6.7.0/hcd/8c317a28866910149816b4a652470b16.html.

VinayKumarS
Active Contributor
0 Likes

if there are any columns are added outside hybris , if you enter the data outside hybris, if you create table outside hybris .. cannot be accessed from hybris. Only the data created by hybris, inserted the data into database from hybris can only be queried and retrieved from hybris.

thanks

0 Likes

Hi Tom.

I don't know if I'm understanding you correctly, but it seems that you added columns to the paymentinfos table directly in the DB.

My question is: why don't you add the attributes via the -items.xml file, like you are supposed to? That way, the properties will be accesible with setters and getters from the Model, without having to use the getAttribute() function, and you will also be able to use it on your flexible search query.

That being said, remember that you can use standard SQL in your flexible search queries; so if you use the column name as it exists on the DB (e.g.: p.p_bankidnumber) without the brackets, that should also work. When you use brackets on a Flexible Search query, Hybris will generate the final SQL query by replacing the brackets with the correct DB names for tables, columns and so on. So, when you use {PaymentInfo as p}, Hybris will replace that with "paymentinfos as p" (as paymentinfos is the table name).