on 2019 May 19 5:03 PM
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)]
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));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
30 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.