cancel
Showing results for 
Search instead for 
Did you mean: 

extended product type not accessible

0 Kudos
200

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)]  


Accepted Solutions (1)

Accepted Solutions (1)

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?

Answers (3)

Answers (3)

dario_petrovic
Discoverer
0 Kudos

Hi ,

Have you checked in ".../hac/console/flexsearch" what do you have in the database. Also, you can easily check catalogversion on items....

 SELECT {fi.pk},{c.id},{cv.version} FROM {FoodItem AS fi JOIN Catalog AS c ON {fi.catalog}={c.pk} JOIN CatalogVersion AS cv ON {fi.catalogversion}={cv.pk}}
sduvvuri
Explorer
0 Kudos

Hello Rajat,

It might be the case that you have imported the FoodItems in Staged version and they have not been synchronized to Online version. Could you please check that as well.

Thanks, Subhash.

bidyadhar_tripathy
Participant
0 Kudos

Hi Rajat,

Did you check , whether you have products with the catalog version : [CatalogVersionModel (8796093121113@1)] or not ?