Sample Query:
SELECT PricebookEntry.Product2.Name
FROM OpportunityLineItem
(Or)
SELECT PricebookEntry.Name
FROM OpportunityLineItem
LIMIT 10
Sample Code:
for (
OpportunityLineItem OLI :
[
SELECT PricebookEntry.Product2.Name,
PricebookEntry.Name
FROM OpportunityLineItem LIMIT 10
]
) {
System.debug(
OLI.PricebookEntry.Product2.Name
);
System.debug(
OLI.PricebookEntry.Name
);
}
Output: