cancel
Showing results for 
Search instead for 
Did you mean: 

HMC: 'typeref' like view with custom query

Former Member
0 Kudos

Hello everybody,

i know that it is possible to create a saved query and it is may not easy to integrate it into the hmc navigation (explorer tree). Source

Maybe i could build a wizard (can i disable the popup for this special wizard?), but maybe there is another (better) way to do that. So i want to ask the experts.

It would be nice if i can use declare in the hmc.xml my view like i know it from "normal" items ('type' inside the hmc.xml) and just controll the query for the result (like hidden and unchangeable attributes).

Some of this hidden query parameter was user access.

Thank you very much for any hint.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It seems that no expert found an answer to my question...

My workaround is now to use 'Personalization' to controll the data that a user see. Maybe someone else can help this.

Answers (2)

Answers (2)

Former Member
0 Kudos

Here's an example:

             <itemtype code="ProductReservationCartOverview" extends="Item" autocreate="true" generate="false" metatype="ViewType" jaloonly="true" jaloclass="de.hybris.platform.util.ViewResultItem">
                 <custom-properties>
                     <property name="query">
                         <value>
                             "SELECT {p:PK}, {s:available}, SUM({i.quantity}) AS reserved, {p:catalogVersion} \n"+
                               "FROM \n"+
                               "{ \n"+
                               "    Product AS p \n"+
                               "    JOIN StockLevelProductRelation AS r ON {r.target} = {p.PK} \n"+
                               "    JOIN StockLevel AS s ON {r.source} = {s.PK} \n"+
                               "    JOIN CartEntry AS i ON {i.product} = {p.PK} \n"+
                               "    JOIN Cart! AS c ON {i.order} = {c.PK} \n"+
                               "} \n"+
                               "WHERE {p.catalogVersion} = ?catalogVersion \n"+
                               "GROUP BY {p:PK}, {s.available} " 
                         </value>
                     </property>
                 </custom-properties>
                 <attributes>
                     <attribute autocreate="true" qualifier="product" type="Product" metatype="ViewAttributeDescriptor">
                            <persistence type="jalo"/>
                            <modifiers read="true" write="false" search="false" initial="false" optional="false"/>
                            <custom-properties>
                                <property name="param"><value>Boolean.FALSE</value></property>
                                <property name="position"><value>Integer.valueOf(0)</value></property>
                            </custom-properties>
                     </attribute>
                     <attribute autocreate="true" qualifier="available" type="java.lang.Integer" metatype="ViewAttributeDescriptor">
                            <persistence type="jalo"/>
                            <modifiers read="true" write="false" search="false" initial="false" optional="false"/>
                            <custom-properties>
                                <property name="param"><value>Boolean.FALSE</value></property>
                                <property name="position"><value>Integer.valueOf(1)</value></property>
                            </custom-properties>
                     </attribute>
                     <attribute autocreate="true" qualifier="reserved" type="java.lang.Integer" metatype="ViewAttributeDescriptor">
                            <persistence type="jalo"/>
                            <modifiers read="true" write="false" search="false" initial="false" optional="false"/>
                            <custom-properties>
                                <property name="param"><value>Boolean.FALSE</value></property>
                                <property name="position"><value>Integer.valueOf(2)</value></property>
                            </custom-properties>
                     </attribute>
                     <attribute generate="false" autocreate="true" qualifier="catalogVersion" type="CatalogVersion" metatype="ViewAttributeDescriptor">
                         <persistence type="jalo"/>
                         <modifiers read="true" write="false" search="true" initial="false" optional="false"/>
                         <custom-properties>
                             <property name="position"><value>Integer.valueOf(3)</value></property>
                             <property name="param"><value>Boolean.TRUE</value></property>
                         </custom-properties>
                     </attribute>
                 </attributes>
               </itemtype>

And expose it in hmc:

 <typeref type="ProductReservationCartOverview" description="typeref.productreservationcartoverview.description"/>
 
     <type name="ProductReservationCartOverview" icon="images/search.gif" mode="append">
         <organizer>
             <search mode="replace">
                 <condition attribute="catalogVersion" operator="equal"/>
             </search>
             <result>
                 <listview mode="replace">
                     <itemlayout>
                         <attribute name="product" width="300"/>
                         <attribute name="available" width="50"/>
                         <attribute name="reserved" width="50"/>
                     </itemlayout>
                 </listview>
             </result>
             <editor>
                 <essentials>
                     <listlayout>
                         <attribute name="product"/>
                         <attribute name="available"/>
                         <attribute name="reserved"/>
                     </listlayout>
                 </essentials>
                 <tab name="properties"/>
                 <tab name="administration" mode="delete"/>
             </editor>
         </organizer>
         <defaultreference mode="replace">
             <itemlayout>
                 <attribute name="product"/>
             </itemlayout>
         </defaultreference>
     </type>
Former Member
0 Kudos

You should create a new itemtype for query, with

metatype="ViewType" jaloonly="true" jaloclass="de.hybris.platform.util.ViewResultItem"