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.
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}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajat,
Did you check , whether you have products with the catalog version : [CatalogVersionModel (8796093121113@1)] or not ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
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.