cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PriceRow to PriceData using PriceService

Former Member
0 Likes
550

Hello,

I have created a custom attribute in PriceRowModel, say someCustomAttr. I need this attribute to be available on the front end as well for the product page. I have multiple price rows for each product and I choose the appropriate PriceInformation using some condition in the PriceService which internally uses PriceFactory. Below is the code snippet for it:

     PriceInformation selectedPrice = null;
     
     final List<PriceInformation> prices = getPriceService().getPriceInformationsForProduct(product);
     for (final PriceInformation price : prices)
     {
         if(some filter condition)
         {
              selectedPrice = price;
          }
       }
   return selectedPrice;


Now that I have the PriceInformation, I can create a PriceData object and assign to the Product. Below is the code snippet for it:

 protected PriceData createPriceData(final PriceDataType priceType, final PriceInformation priceInfo)
 {
     return getPriceDataFactory().create(priceType, BigDecimal.valueOf(priceInfo.getPriceValue().getValue()),
                 priceInfo.getPriceValue().getCurrencyIso());
 }

But how can I populate my custom attribute from PriceRowModel to PriceData. Kindly provide a recommended approach for this.

Thanks in advance!

Accepted Solutions (0)

Answers (0)