Manigandan Karthick
Manigandan Karthick

Reputation: 63

Hybris Custom WSDTO on hybris product data

Hi I had created eProductForm bean in the commerecefacades-beans.xml I added custom attribute of ProductData.

<bean class="de.hybris.platform.commercefacades.product.data.ProductData">
<property name="eProductForm" type="String"/>    
</bean>

then in commercewebservice-beans.xml, I added the custom attribute of ProductWsDTO

<bean class="de.hybris.platform.commercewebservicescommons.dto.product.ProductWsDTO">
<property name="eProductForm" type="String"/></bean>

from SearchResultProductPopulator populated productdata of eProductForm from my search result.

target.setEProductForm(this.<String> getValue(source, "E_PRODUCT_FORM"));

PFB dto mapping

<bean parent="fieldSetLevelMapping" id="productWsDTOFieldSetLevelMapping">
 <property name="dtoClass"   value="de.hybris.platform.commercewebservicescommons.dto.product.ProductWsDTO"/>
<property name="levelMapping">
<map>
<entry key="BASIC"
      value="purchasable,stock,name,baseProduct,availableForPickup,code,url,price"/>
<entry key="DEFAULT"
      value="summary,averageRating,purchasable,stock(DEFAULT),description,variantMatrix(DEFAULT),name,baseOptions(DEFAULT),baseProduct,availableForPickup,variantOptions(DEFAULT),code,url,price(DEFAULT),numberOfReviews,manufacturer,categories(BASIC),priceRange,multidimensional,configuratorType,configurable,tags"/>
<entry key="FULL"
      value="summary,productReferences(FULL),classifications(FULL),averageRating,purchasable,volumePrices(FULL),variantType,stock(FULL),description,variantMatrix(FULL),name,baseOptions(FULL),baseProduct,availableForPickup,variantOptions(FULL),reviews(FULL),code,url,price(FULL),numberOfReviews,manufacturer,volumePricesFlag,futureStocks(FULL),images(FULL),categories(FULL),potentialPromotions(FULL),priceRange,multidimensional,configuratorType,configurable,tags,eProductForm,ePickledGroup"/>
</map>
</property>
</bean>

Below is the code I am calling Mapper.. While I debugged my code sourceresult is having product data of that custom attreibute. But I am not getting the eproductform in the WSDTO response.

final ProductSearchPageData<SearchStateData, ProductData> sourceResult = searchProducts(query, currentPage, pageSize, sort);
    if (sourceResult instanceof ProductCategorySearchPageData)
    {
        return getDataMapper().map(sourceResult, ProductCategorySearchPageWsDTO.class, fields);
    }

But in logs I see:

[EL Warning]: 2019-02-20 18:31:27.341--Ignoring attribute [eProductForm] on class [de.hybris.platform.commercewebservicescommons.dto.product.ProductWsDTO] as no Property was generated for it.

Upvotes: 4

Views: 4694

Answers (1)

geffchang
geffchang

Reputation: 3340

As @Farrukh Chishti commented, the URL that you used probably used the DEFAULT level, which doesn't contain the attribute you added. For testing purposes, you can try to add the attribute to BASIC, DEFAULT, and FULL.

In the URL, you can specify the level, something like this:

https://localhost:9002/rest/v2/custom_site/stores?&fields=FULL

Upvotes: 2

Related Questions