Hi Nithya, Try the below query, it may be helpful for you:
List<Opportunity> oppList = [SELECT Id, Name, Account.Name,(SELECT Quantity, UnitPrice, TotalPrice,PricebookEntry.Name, PricebookEntry.Product2.Family FROM OpportunityLineItems) FROM Opportunity WHERE Id = :'0060o00001D774JAAR'];
System.debug('oppList-->'+oppList);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too. Thanks, Ajay Dubedi
Select PriceBookEntry.Product2.Id,PriceBookEntry.Product2.Name from OpportunityLineItem where OpportunityId= :OppId
Try the below query, it may be helpful for you:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi