I have a custom Product search Lightning component on the Opportunity page and I need to change the second field in the search results below to display another field. Right now it shows the Product2.Name and the Product2.Cat_Class__c. I need the search results to show the Product2.Name and the Product2.ProductCode fields.

Two fields in search results displayed

This is a custom Lightning Component in an instance of Salesforce that my firm just took over. Unfortunately there is no documentation and I can't seem to figure out where to make the change.

If I edit the Opportunity page and click on the component I can see this:

Custom Component: opportunityProductSearch

If I go to Setup and lookup Lightning Components I find this:

Lightning Component with matching name

I can't find the LWC called opportunityProductSearch anywhere else in the system. I've searched all Lightning Resources in the Developer Console. I am able to see the Apex Class called opportunityProductController and I see the code written to do the search and I have been able to find the corresponding Class in the Sandbox. However, I cannot figure out how to change the second field that is displayed in the search results and I cannot find documentation on the web for this.

Again, I need the search results to show the Product2.Name and the Product2.ProductCode fields. Right now it shows the Product2.Name and the Product2.Cat_Class__c

public static List<PricebookEntry> getSearchResults(String searchString, Id pricebookId) {
    searchString = searchString.trim();
    String fuzzyString = '%' + searchString + '%';
    if (searchString.length() > 2 && priceBookId != null) {
        List<List<SObject>> searchList = [FIND : searchString IN ALL FIELDS RETURNING Product2(Id WHERE IsActive = true)];
        List<Product2> fuzzyList = [SELECT Id FROM Product2
                                    WHERE IsActive = true
                                    AND (Name LIKE : fuzzyString
                                    OR ProductCode LIKE : fuzzyString
                                    OR Cat_Class__c LIKE : fuzzyString
                                    OR Family LIKE : fuzzyString 
                                    OR Model_s__c LIKE : fuzzyString 
                                    OR Model_s_1__c LIKE : fuzzyString 
                                    OR Model_s_2__c LIKE : fuzzyString 
                                    OR Model_s_3__c LIKE : fuzzyString 
                                    OR Equipment_IDs__c LIKE : fuzzyString 
                                    OR Equipment_IDs_1__c LIKE : fuzzyString 
                                    OR Equipment_IDs_2__c LIKE : fuzzyString 
                                    OR Equipment_IDs_3__c LIKE : fuzzyString)
        List<Product2> productIds = searchList[0];
        if (!productIds.isEmpty()) {
            return[SELECT Id, UnitPrice, Product2.Id, Product2.Name, Product2.ProductCode, Product2.Cat_Class__c, 
                   Product2.Model_s__c, Product2.Model_s_1__c, Product2.Model_s_2__c, Product2.Model_s_3__c, 
                   Product2.Rouse_Daily_Book_Rate__c, Product2.Rouse_Weekly_Book_Rate__c, Product2.Rouse_Monthly_Book_Rate__c
                   FROM PricebookEntry WHERE Pricebook2Id = : pricebookId AND IsActive = true AND Product2Id IN : productIds
                   ORDER BY Product2.Name ASC LIMIT 100];
        } else {
            return new List<PricebookEntry> ();
    } else {
        return new List<PricebookEntry> ();

@AuraEnabled(cacheable = true)
public static List<String> getFieldSetFields(String fieldSetApiName) {
    List<String> fields = new List<String> ();
    List<Schema.FieldSetMember> fieldSetMembers = SObjectType.Opportunity.FieldSets ?.getMap() ?.get(fieldSetApiName) ?.getFields();
    if (fieldSetMembers != null) {
        for (Schema.FieldSetMember fieldSetMember : fieldSetMembers) {
    return fields;

2 Answers 2


You are not able to search component from developer console as it LWC Component. LWC Component we are not able to work in it in dev console. For working in LWC you need to install VS Code and then you can link your org with VS code.

Here is step by step doc to install VS Code VS CODE

If you need to search results through Product2.ProductCode instead of Product2.Cat_Class__c then you need to make change in your LWC. Once you are able to install VS code and link your org then open your LWC and in component code replace Product2.Cat_Class__c with Product2.ProductCode.


I thing you should customize Search Layout

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .