cancel
Showing results for 
Search instead for 
Did you mean: 

extended product type not accessible

0 Kudos
226

i have created a new itemtype fooditem extending product type as below:

 <itemtype code="FoodItem" extends="Product">
             <description>food items</description>
             <attributes>
                 <attribute type="java.lang.Integer" qualifier="price">
                     <persistence type="property"></persistence>
                 </attribute>
             </attributes>
         </itemtype>  

i successfully added 20 rows using impex as follows:

 insert_update FOODITEM  PRICE ; NAME; CODE[unique=true] ; CATALOGVERSION(catalog(id),version)[unique=true] ;  

but when i am trying to access the rows in DAO layer, the flexibleSearchService is returning 0 rows.
The DAO layer code snippet is like below:

 public List<FoodItemModel> getAllFood()
     {
         // XXX Auto-generated method stub
 
         //        catalogVersionService.setSessionCatalogVersion("FoodInSystems", "Online");
         final String query = "select {pk} from {fooditem}";
         final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);
         final List<FoodItemModel> items = flexibleSearchService.<FoodItemModel> search(fQuery).getResult();
         LOG.info(fQuery.toString());
         LOG.info("In " + DefaultFoodItemDAO.class.toString() + " , we found " + Integer.toString(items.size()) + " food items");
         LOG.info(Integer.toString(catalogVersionService.getSessionCatalogVersions().size()));
 
         LOG.info(catalogVersionService.getSessionCatalogVersions().toString());
 
         return items;
     }  

and the output looks like below:

 INFO  [hybrisHTTP29] [DefaultFoodItemDAO] query: [select {pk} from {fooditem}], query parameters: [{}]
 INFO  [hybrisHTTP29] [DefaultFoodItemDAO] In class com.infy.daos.impl.DefaultFoodItemDAO , we found 0 food items
 INFO  [hybrisHTTP29] [DefaultFoodItemDAO] 1
 INFO  [hybrisHTTP29] [DefaultFoodItemDAO] [CatalogVersionModel (8796093121113@1)]  


View Entire Topic
former_member620692
Active Contributor
0 Kudos

Please change your query as follows and try again:

 final String query = "SELECT {p:" + FoodItemModel.PK + "} FROM {" + FoodItemModel._TYPECODE + " AS p} ";

EDIT on 21-May-2019:

If you are getting the result in hAC but not through the code, please add the following code before calling flexibleSearchService.search and try again:

 sessionService.setAttribute(SessionContext.USER, userService.getUser(Constants.USER.ADMIN_EMPLOYEE));
0 Kudos

hello , it is still not working. I am doing this in yempty extension template, does that matter?