function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sf ostsf ost 

display pricebook products on visualforce page

I need to display products in Order object. We are using 'Order Products (Pricebook)' standard object which is in lookup with 'Orders'. But i am unable to find api name of 'Order Products' standard object to query them products selected from pricebook.

I need to show both "order details" and "products in order (Order Products)" details.

My contoller code. Working for only retriving orders. Not working for quering order products (Pricebook)
public with sharing class OrdersController {

    public List<Order> orderList {get;set;}
    public OrdersController(){
        orderList = new List<Order>();
    public List<Order> getOrders(){
        return [SELECT OrderNumber, TotalAmount, Status (Select Product2Id, Product2.Name From PricebookEntry__r Where Product2Id =: productdet) FROM Order WHERE OwnerID=: UserInfo.getUserId()];
My VF code:
<apex:page controller="OrdersController" showHeader="false">

<script type="text/javascript" src=""></script>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        $('#viewDetails').click(function () {
            if ($("#pnl_details").is(":hidden")) {
                $("#viewDetails").html("Show Less Details");
                 return false;
            } else {
                $("#viewDetails").html("Show More Details");
             return false;

  <apex:pageBlock >
  <!-- <apex:repeat value="{!Orders}" var="owd">
</apex:repeat> -->
  <apex:pageBlockSection title="Orders" id="pnl_details" columns="1">
        <apex:pageBlockTable value="{!orders}" var="o">
            <!-- <apex:column headerValue="Order Number">
                <apex:commandLink action="{!URLFOR($Action.Order.View,}" value="{!o.OrderNumber}"/>
            </apex:column> -->
            <apex:column value="{!o.OrderNumber}"/>
            <apex:column value="{!o.TotalAmount}" />
            <apex:column value="{!o.Status}" />
<apex:pageBlockSection columns="1">
    <apex:relatedList list="Pricebook2 " />


help me in this.

This is Sample Query you can use to retrive Order Product and product infromation.

SELECT OrderItemNumber,Quantity,UnitPrice,PricebookEntry.Name FROM OrderItem

API name for Order Product is orderitem.

Hope this will resolve your problem.

~Onkar Kumar