You need to sign in to do that
Don't have an account?
How to display a Price related to Product in Visaulforce page.
Hi all,
First of all thanks for giving your valuable time to look at my post.
I have a simple requirment to display the price list related to product in visualforce page. I have created a wrapper class to display Prodcut name , code but i dont know how to display price of the associated product. here what I am trying to do ...
Wrapper class :
public class ProductWarpper{
public Product2 prodObj{get;set;}
public boolean isSelected {get;set;}
public integer quantity {get;set;}
public list<integer> price {get;set;}
}
public PageReference selectedValue() {
selectedProd = new list<ProductWarpper>();
for(ProductWarpper cCon:getProdName()){
if(cCon.isSelected ==true)
{
selectedProd.add(cCon);
}
}
set<id> pids = new set<id>();
for(ProductWarpper p: selectedProd){
pids.add(p.prodObj.id);
}
system.debug('new id' + pids);
prbkentry =[select UnitPrice from pricebookentry where Product2Id in :pids];
system.debug('Unit Price' + prbkentry);
for(integer i=0;i>= prbkentry.size();i++ ){
pricebook.add(Integer.valueOf(prbkentry[i].UnitPrice));
}
return null;
}
public list<ProductWarpper> getProdName(){
lstProd= [select Name,Category__c,id,ProductCode from product2 where Name like :'%'+searchkey +'%' or Category__c like : '%'+searchkey +'%' or ProductCode like : '%'+searchkey +'%' ];
for(product2 prod : lstProd){
ProductWarpper prodwap = new ProductWarpper();
prodwap.prodObj= prod;
lsPwr.add(prodwap);
}
return lsPwr;
}
this is my Vf page where I am displaying the filed value :
<apex:pageBlockTable value="{!lsPwr}" var="tmpVar">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!tmpVar.isSelected}"/>
</apex:column>
<apex:column value="{!tmpVar.prodObj.name}" headerValue="Product Name"/>
<apex:column value="{!tmpVar.prodObj.ProductCode}" headerValue="Product code"/>
<apex:column value="{!tmpVar.prodObj.Category__c}" headerValue="Product Category"/>
<apex:column value="{!tmpVar.price}" headerValue="Product Price"/>
<apex:inputtext value="{!tmpVar.quantity }" label="Quantity"/>
</apex:pageBlockTable>
</apex:pageBlock>
please help me to solve my issue.
Thanks & Regards,
Amit_
For more details have a look at this link http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_pricebookentry.htm
Thanks for your reply. but my issue is to display the price on vf page using wrapper class.
I am quring pricebookentry table to get the unit price associated with the product2 id.
but i need to display it on vf page.
for(ProductWarpper p: selectedProd){
pids.add(p.prodObj.id);
}
system.debug('new id' + pids);
prbkentry =[select UnitPrice from pricebookentry where Product2Id in :pids];
public class ProductWarpper{
public Product2 prodObj{get;set;}
public boolean isSelected {get;set;}
public integer quantity {get;set;}
public list<integer> price {get;set;}
}
how will I assign the unit price to the price varibale of warpper class and to dispaly it on vf page.
Thanks & regards,
Amit_
the same.
You can always access the product fields from child records, isnt it?
I am using pagebloacktable to disaplay the values on vf page using wrapper class list, how can I use another wrapper class list to display the value on the same pageblocktable. I think that is not possible.
I suggested
For the suggetion, i will try to change my wrapper class and see if its working
Thanks Again
Regards
Amit_