Skip to Content
0
Aug 17, 2023 at 01:25 PM

How to add a new attribute to Existing Product Model, display in PDP and PLP ?

114 Views Last edit Aug 18, 2023 at 12:48 PM 3 rev

Add a new attribute called discountAmount to the Product model and show that attribute in PLP and PDP.

hint:- We all know that most of the product attributes are indexed which means they will be retrieved from the Solr when we do the search of a product.

*Use ValueResolver ( ValueProvider is Deprecated) .

Steps i have followed:

Step-1: added an attribute discountAmount(Double) under Product.

Step-2: ant clean all & refresh eclipse, then updated my core extension in HAC

step-3: created an ValueResolver & registered in sping.xml(in core extension)

step-4: added my discountAmount in beans.xml in ProductData in facades & ant all refresh eclipse as well as HAC.

Step-5: created 2 Populators to populate the data from Provider to PLP,PLP to PDP. & registered in spring.xml(in facades extension).

step-5: modified productListerprice.tag & productPricePanel.tag files.

step-6: run the impex for solr in HAC

INSERT_UPDATE SolrIndexedProperty;solrIndexedType(identifier)[unique = true];name[unique = true];type(code);sortableType(code);currency[default = true]; localized[default = false]; multiValue[default = false]; facet[default = false]; facetType(code); facetSort(code); priority; visible; useForSpellchecking[default = false]; useForAutocomplete[default = false]; fieldValueProvider; facetDisplayNameProvider; customFacetSortProvider; topValuesProvider; rangeSets(name)

;$solrIndexedType;discountAmount ;double;;true;;;;;;;;;;sitediscountPriceValueProvider;;;;

I tried above task with new itemType having attributes code,sitediscount in XYZ itemtype & took 1 more attribute in CMSSite named discountAmount to display in entire site. It has been worked .

But my task is to take only 1 attribute(discountAmount ) in ProductModel ?

Expected ouput : In PLP page and PDP page three labels should display like:-

Original Price: 100

Discounted Price:10 or 10%

Selling Price:90