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
SFDC@ErrorSFDC@Error 

Record is not Showing in Vf page

HI All I have created a Page for custom prodcut display with images .but here i am struggling for record is not showing .Like below.Can any body corect me.

User-added image
 
public class ProductSearchController {

  // the soql without the order and limit
    private String soql {get;set;}
    public Boolean showPageBlock{get;set;}
    // the collection of products to display
    public List<Product__c> products {get;set;}
    Integer counter = 0;//TO track the number of records parsed
    Integer limitSize = 20;//Number of records to be displayed
    Integer totalSize =0; //To Store the total number of records available
    public List<Product__c> ProductsToShow{get;set;}
    // the current sort direction. defaults to asc
    public String sortDir {
        get  
        { 
            if (sortDir == null) 
            {  
                sortDir = 'asc'; 
            } 
            return sortDir;  
        }
        set;
    }

  // the current field to sort by. defaults to last name
    public String sortField {
        get  
        { 
            if (sortField == null) 
            {
                sortField = 'Name'; 
            } 
            return sortField;  
        }
        set;
    }

  // format the soql for display on the visualforce page
    public String debugSoql {
        get 
        { 
            return soql + ' order by ' + sortField + ' ' + sortDir; 
        }
        set;
    }

    // init the controller and display some sample data when the page loads
    public ProductSearchController() {
        showPageBlock = true;
       
        productsToShow = new list<Product__c>();
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,Stock__c,ImageUrl__c,PictureUpload__c,Metal__c,Collection_Name__c,Stone_Shape__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
        
        
        runQuery();
    }

    // toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

    // runs the actual query
    public void runQuery() {
   
   
    productsToShow = new list<Product__c>();
    
        
      }
        
     
    

    // runs the search with parameters passed via Javascript
    public PageReference runSearch() {
        String Name= Apexpages.currentPage().getParameters().get('Name'); 
        String productType = Apexpages.currentPage().getParameters().get('productType'); 
        String imageUrl = Apexpages.currentPage().getParameters().get('imageUrl');  
        String metal = Apexpages.currentPage().getParameters().get('metal');
        String collectionName = Apexpages.currentPage().getParameters().get('collectionName');
        String stoneType = Apexpages.currentPage().getParameters().get('stoneType');
        String semiPrecious = Apexpages.currentPage().getParameters().get('semiPrecious');
        String stoneOther = Apexpages.currentPage().getParameters().get('stoneOther');
        String centerOther = Apexpages.currentPage().getParameters().get('centerOther');
        String stoneShape = Apexpages.currentPage().getParameters().get('stoneShape');
        String stoneWeight = Apexpages.currentPage().getParameters().get('stoneWeight');
        String centerFromColor = Apexpages.currentPage().getParameters().get('centerFromColor');
        //String centerToColor = Apexpages.currentPage().getParameters().get('centerToColor');
        String clarityCenterFrom = Apexpages.currentPage().getParameters().get('clarityCenterFrom');
        //String clarityCenterTo = Apexpages.currentPage().getParameters().get('clarityCenterTo');
        String certificateType = Apexpages.currentPage().getParameters().get('certificateType');
        String fromTagPrice = Apexpages.currentPage().getParameters().get('fromTagPrice');
        String toTagPrice = Apexpages.currentPage().getParameters().get('toTagPrice');
       
        
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,ImageUrl__c,Stock__c,PictureUpload__c,Metal__c,Collection_Name__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
       
        if (!productType.equals(''))
            soql += ' and Product_Type__c LIKE \''+String.escapeSingleQuotes(productType)+'%\'';
      
        if (!imageUrl.equals(''))
            soql += ' and ImageUrl__c LIKE \''+String.escapeSingleQuotes(imageUrl)+'%\''; 
        
        if (!metal.equals(''))
            soql += ' and Metal__c LIKE \''+String.escapeSingleQuotes(metal)+'%\'';
        
        if (!collectionName.equals(''))
            soql += ' and Collection_Name__c LIKE \''+String.escapeSingleQuotes(collectionName)+'%\''; 
        
        if (!stoneWeight.equals(''))
            soql += ' and Stone_Weight_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneWeight)+'\')';
        
        if (!centerFromColor.equals(''))
            soql += ' and Color_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerFromColor)+'\')';  
        /*
        if (!centerToColor.equals(''))
            soql += ' and Color_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerToColor)+'\')';
        */
        if (!clarityCenterFrom.equals(''))
            soql += ' and Clarity_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterFrom)+'\')';
        /*       
        if (!clarityCenterTo.equals(''))
            soql += ' and Clarity_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterTo)+'\')';
        */
        if (!certificateType.equals(''))
            soql += ' and Certificate_Type_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(certificateType)+'\')';
        
        if (!fromTagPrice.equals(''))
            soql += ' and Tag_Price__c >= '+String.escapeSingleQuotes(fromTagPrice)+'';
            
        if (!toTagPrice.equals(''))
            soql += ' and Tag_Price__c <= '+String.escapeSingleQuotes(toTagPrice)+'';
        
        if (!stoneType.equals(''))
            soql += ' and Stone_Type_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneType)+'\')';  
            
        if (!semiPrecious.equals(''))
            soql += ' and Semi_Precious_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(semiPrecious)+'\')';
        
        if (!stoneOther.equals(''))
            soql += ' and Stone_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneOther)+'\')';
            
        if (!centerOther.equals(''))
            soql += ' and Center_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerOther)+'\')';  
        
        
        if (!stoneShape.equals(''))
            soql += ' and Stone_Shape_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneShape)+'\')';
            
        // run the query again
        runQuery();

        return null;
      }
      
    public List<String> listProductTypes{
    get {
       
            listProductTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Product_Type__c.getDescribe();
            
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listProductTypes.add(f.getLabel());
         
         return listProductTypes;          
         }
    set;
    }
    
    public List<String> listMetal{
    get {
        if (listMetal == null) {
            listMetal = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Metal__c.getDescribe();

            for (Schema.PicklistEntry f : field.getPicklistValues())
                listMetal.add(f.getLabel());
            
        }
        return listMetal;          
    }
    set;
    }
    
    public List<String> listCollectionTypes{
    get {
        if (listCollectionTypes == null) {
            listCollectionTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Collection_Name__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
              listCollectionTypes.add(f.getLabel());
        }
        return listCollectionTypes;          
    }
    set;
    }
    
    public List<String> listStoneTypes{
    get {
        if (listStoneTypes == null) {
            listStoneTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneTypes.add(f.getLabel());
    
        }
      return listStoneTypes;          
    }
    set;
    }
    
    
    /*
    public List<String> listSemiPrecious{
    get {
        if (listSemiPrecious == null) {
            listSemiPrecious = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Semi_Precious__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listSemiPrecious.add(f.getLabel());
    
        }
      return listSemiPrecious;          
    }
    set;
    }
    */
    
    public List<String> listStoneShapes{
    get {
        if (listStoneShapes == null) {
            listStoneShapes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Shape_Center__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneShapes.add(f.getLabel());
    
        }
        return listStoneShapes;          
    }
    set;
    }
    /*
    public List<String> listColors{
    get {
        if (listColors == null) {
            listColors = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Color__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listColors.add(f.getLabel());
    
        }
        return listColors;          
    }
    set;
    }
    */
    
    public List<String> listCenterFromColors{
    get {
        if (listCenterFromColors == null) {
            listCenterFromColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromColors.add(f.getLabel());
    
        }
        return listCenterFromColors;          
    }
    set;
    }
    /*
    public List<String> listCenterToColors{
    get {
        if (listCenterToColors == null) {
            listCenterToColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_To__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterToColors.add(f.getLabel());
    
        }
        return listCenterToColors;          
    }
    set;
    }
    */
    /*
    public List<String> listClarities{
    get {
        if (listClarities == null) {
            listClarities = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Clarity__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listClarities.add(f.getLabel());
        }
        return listClarities;          
    }
    set;
    }
    */
    public List<String> listCenterFromClarity{
    get {
        if (listCenterFromClarity == null) {
            listCenterFromClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromClarity.add(f.getLabel());
        }
        return listCenterFromClarity;          
    }
    set;
    }
    /*
    public List<String> listCenterToClarity{
    get {
        if (listCenterToClarity == null) {
            listCenterToClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_To__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterToClarity.add(f.getLabel());
        }
        return listCenterToClarity;          
    }
    set;
    }
    */
    public List<String> listCertificateTypes{
    get {
        if (listCertificateTypes == null) {
            listCertificateTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Certificate_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCertificateTypes.add(f.getLabel());
        }
        return listCertificateTypes;          
    }
    set;
    }
    
    public void beginning(){
   
        productsToShow.clear();
        counter=0;
        if((counter + limitSize) <= totalSize){
       
            for(Integer i=0;i<limitSize;i++){
                productsToShow.add(products.get(i));
            }   
           
        } else{
       
            for(Integer i=0;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }       
           
        }
    }
    
    public void next(){
   
        productsToShow.clear();
        counter=counter+limitSize;
       
        if((counter+limitSize) <= totalSize){
            for(Integer i=counter;i<(counter+limitSize);i++){
                productsToShow.add(products.get(i));
            }
        } else{
            for(Integer i=counter;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }
        }
    }
   
    public void previous(){
    
        productsToShow.clear();
    
        counter=counter-limitSize;       
       
        for(Integer i=counter;i<(counter+limitSize); i++){
            productsToShow.add(products.get(i));
        }
    }
    
    public void last (){
   
        productsToShow.clear();
       
        if(math.mod(totalSize , limitSize) == 0){
            counter = limitSize * ((totalSize/limitSize)-1);
        } else if (math.mod(totalSize , limitSize) != 0){
            counter = limitSize * ((totalSize/limitSize));
        }
       
        for(Integer i=counter-1;i<totalSize-1;i++){
                productsToShow.add(products.get(i));
        }
       
    }
    
    public Boolean getDisableNext(){
   
        if((counter + limitSize) >= totalSize )
            return true ;
        else
            return false ;
    }
    
    public Boolean getDisablePrevious(){
   
        if(counter == 0)
            return true ;
        else
            return false ;
    } 
}
Keyur  ModiKeyur Modi

Hi SFDC@Error,

I have removed commneted code from your code snipet and Below is your code without comment.
 

public class ProductSearchController {

  // the soql without the order and limit
    private String soql {get;set;}
    public Boolean showPageBlock{get;set;}
    // the collection of products to display
    public List<Product__c> products {get;set;}
    Integer counter = 0;//TO track the number of records parsed
    Integer limitSize = 20;//Number of records to be displayed
    Integer totalSize =0; //To Store the total number of records available
    public List<Product__c> ProductsToShow{get;set;}
    // the current sort direction. defaults to asc
    public String sortDir {
        get  
        { 
            if (sortDir == null) 
            {  
                sortDir = 'asc'; 
            } 
            return sortDir;  
        }
        set;
    }

  // the current field to sort by. defaults to last name
    public String sortField {
        get  
        { 
            if (sortField == null) 
            {
                sortField = 'Name'; 
            } 
            return sortField;  
        }
        set;
    }

  // format the soql for display on the visualforce page
    public String debugSoql {
        get 
        { 
            return soql + ' order by ' + sortField + ' ' + sortDir; 
        }
        set;
    }

    // init the controller and display some sample data when the page loads
    public ProductSearchController() {
        showPageBlock = true;
       
        productsToShow = new list<Product__c>();
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,Stock__c,ImageUrl__c,PictureUpload__c,Metal__c,Collection_Name__c,Stone_Shape__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
        
        
        runQuery();
    }

    // toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

    // runs the actual query
    public void runQuery() {
   
   
    productsToShow = new list<Product__c>();
    
        
      }
        
     
    

    // runs the search with parameters passed via Javascript
    public PageReference runSearch() {
        String Name= Apexpages.currentPage().getParameters().get('Name'); 
        String productType = Apexpages.currentPage().getParameters().get('productType'); 
        String imageUrl = Apexpages.currentPage().getParameters().get('imageUrl');  
        String metal = Apexpages.currentPage().getParameters().get('metal');
        String collectionName = Apexpages.currentPage().getParameters().get('collectionName');
        String stoneType = Apexpages.currentPage().getParameters().get('stoneType');
        String semiPrecious = Apexpages.currentPage().getParameters().get('semiPrecious');
        String stoneOther = Apexpages.currentPage().getParameters().get('stoneOther');
        String centerOther = Apexpages.currentPage().getParameters().get('centerOther');
        String stoneShape = Apexpages.currentPage().getParameters().get('stoneShape');
        String stoneWeight = Apexpages.currentPage().getParameters().get('stoneWeight');
        String centerFromColor = Apexpages.currentPage().getParameters().get('centerFromColor');
        //String centerToColor = Apexpages.currentPage().getParameters().get('centerToColor');
        String clarityCenterFrom = Apexpages.currentPage().getParameters().get('clarityCenterFrom');
        //String clarityCenterTo = Apexpages.currentPage().getParameters().get('clarityCenterTo');
        String certificateType = Apexpages.currentPage().getParameters().get('certificateType');
        String fromTagPrice = Apexpages.currentPage().getParameters().get('fromTagPrice');
        String toTagPrice = Apexpages.currentPage().getParameters().get('toTagPrice');
       
        
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,ImageUrl__c,Stock__c,PictureUpload__c,Metal__c,Collection_Name__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
       
        if (!productType.equals(''))
            soql += ' and Product_Type__c LIKE \''+String.escapeSingleQuotes(productType)+'%\'';
      
        if (!imageUrl.equals(''))
            soql += ' and ImageUrl__c LIKE \''+String.escapeSingleQuotes(imageUrl)+'%\''; 
        
        if (!metal.equals(''))
            soql += ' and Metal__c LIKE \''+String.escapeSingleQuotes(metal)+'%\'';
        
        if (!collectionName.equals(''))
            soql += ' and Collection_Name__c LIKE \''+String.escapeSingleQuotes(collectionName)+'%\''; 
        
        if (!stoneWeight.equals(''))
            soql += ' and Stone_Weight_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneWeight)+'\')';
        
        if (!centerFromColor.equals(''))
            soql += ' and Color_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerFromColor)+'\')';  
       
        if (!clarityCenterFrom.equals(''))
            soql += ' and Clarity_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterFrom)+'\')';
       
        if (!certificateType.equals(''))
            soql += ' and Certificate_Type_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(certificateType)+'\')';
        
        if (!fromTagPrice.equals(''))
            soql += ' and Tag_Price__c >= '+String.escapeSingleQuotes(fromTagPrice)+'';
            
        if (!toTagPrice.equals(''))
            soql += ' and Tag_Price__c <= '+String.escapeSingleQuotes(toTagPrice)+'';
        
        if (!stoneType.equals(''))
            soql += ' and Stone_Type_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneType)+'\')';  
            
        if (!semiPrecious.equals(''))
            soql += ' and Semi_Precious_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(semiPrecious)+'\')';
        
        if (!stoneOther.equals(''))
            soql += ' and Stone_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneOther)+'\')';
            
        if (!centerOther.equals(''))
            soql += ' and Center_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerOther)+'\')';  
        
        
        if (!stoneShape.equals(''))
            soql += ' and Stone_Shape_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneShape)+'\')';
            
        // run the query again
        runQuery();

        return null;
      }
      
    public List<String> listProductTypes{
    get {
       
            listProductTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Product_Type__c.getDescribe();
            
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listProductTypes.add(f.getLabel());
         
         return listProductTypes;          
         }
    set;
    }
    
    public List<String> listMetal{
    get {
        if (listMetal == null) {
            listMetal = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Metal__c.getDescribe();

            for (Schema.PicklistEntry f : field.getPicklistValues())
                listMetal.add(f.getLabel());
            
        }
        return listMetal;          
    }
    set;
    }
    
    public List<String> listCollectionTypes{
    get {
        if (listCollectionTypes == null) {
            listCollectionTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Collection_Name__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
              listCollectionTypes.add(f.getLabel());
        }
        return listCollectionTypes;          
    }
    set;
    }
    
    public List<String> listStoneTypes{
    get {
        if (listStoneTypes == null) {
            listStoneTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneTypes.add(f.getLabel());
    
        }
      return listStoneTypes;          
    }
    set;
    }
    
    public List<String> listStoneShapes{
    get {
        if (listStoneShapes == null) {
            listStoneShapes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Shape_Center__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneShapes.add(f.getLabel());
    
        }
        return listStoneShapes;          
    }
    set;
    }
    
    public List<String> listCenterFromColors{
    get {
        if (listCenterFromColors == null) {
            listCenterFromColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromColors.add(f.getLabel());
    
        }
        return listCenterFromColors;          
    }
    set;
    }
    
    public List<String> listCenterFromClarity{
    get {
        if (listCenterFromClarity == null) {
            listCenterFromClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromClarity.add(f.getLabel());
        }
        return listCenterFromClarity;          
    }
    set;
    }
   
    public List<String> listCertificateTypes{
    get {
        if (listCertificateTypes == null) {
            listCertificateTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Certificate_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCertificateTypes.add(f.getLabel());
        }
        return listCertificateTypes;          
    }
    set;
    }
    
    public void beginning(){
   
        productsToShow.clear();
        counter=0;
        if((counter + limitSize) <= totalSize){
       
            for(Integer i=0;i<limitSize;i++){
                productsToShow.add(products.get(i));
            }   
           
        } else{
       
            for(Integer i=0;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }       
           
        }
    }
    
    public void next(){
   
        productsToShow.clear();
        counter=counter+limitSize;
       
        if((counter+limitSize) <= totalSize){
            for(Integer i=counter;i<(counter+limitSize);i++){
                productsToShow.add(products.get(i));
            }
        } else{
            for(Integer i=counter;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }
        }
    }
   
    public void previous(){
    
        productsToShow.clear();
    
        counter=counter-limitSize;       
       
        for(Integer i=counter;i<(counter+limitSize); i++){
            productsToShow.add(products.get(i));
        }
    }
    
    public void last (){
   
        productsToShow.clear();
       
        if(math.mod(totalSize , limitSize) == 0){
            counter = limitSize * ((totalSize/limitSize)-1);
        } else if (math.mod(totalSize , limitSize) != 0){
            counter = limitSize * ((totalSize/limitSize));
        }
       
        for(Integer i=counter-1;i<totalSize-1;i++){
                productsToShow.add(products.get(i));
        }
       
    }
    
    public Boolean getDisableNext(){
   
        if((counter + limitSize) >= totalSize )
            return true ;
        else
            return false ;
    }
    
    public Boolean getDisablePrevious(){
   
        if(counter == 0)
            return true ;
        else
            return false ;
    } 
}


If you see that you have only constructed string query but you are not quering from data base. You are trying to query dynamically. 
for example

//Example :- 

String strQuery = 'SELECT Id FROM Account';
List<Account> lstAccount = database.Query(strQuery);

//Update your code with below query

ProductsToShow = Database.Query(soql); 

Refer below link for the Dynamic SOQL query. 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm

Let me know if you need any further guidance on this.

Thanks,
Keyur Modi

SFDC@ErrorSFDC@Error
Hay Modi 

I have tried but facing same issue...
public class ProductSearchController {

  // the soql without the order and limit
    private String soql {get;set;}
    public Boolean showPageBlock{get;set;}
    // the collection of products to display
    public List<Product__c> products {get;set;}
    Integer counter = 0;//TO track the number of records parsed
    Integer limitSize = 20;//Number of records to be displayed
    Integer totalSize =0; //To Store the total number of records available
    public List<Product__c> ProductsToShow{get;set;}
    // the current sort direction. defaults to asc
    public String sortDir {
        get  
        { 
            if (sortDir == null) 
            {  
                sortDir = 'asc'; 
            } 
            return sortDir;  
        }
        set;
    }

  // the current field to sort by. defaults to last name
    public String sortField {
        get  
        { 
            if (sortField == null) 
            {
                sortField = 'Name'; 
            } 
            return sortField;  
        }
        set;
    }

  // format the soql for display on the visualforce page
    public String debugSoql {
        get 
        { 
            return soql + ' order by ' + sortField + ' ' + sortDir; 
        }
        set;
    }

    // init the controller and display some sample data when the page loads
    public ProductSearchController() {
        showPageBlock = true;
       
        productsToShow = new list<Product__c>();
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,Stock__c,ImageUrl__c,PictureUpload__c,Metal__c,Collection_Name__c,Stone_Shape__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
        
        
        runQuery();
    }

    // toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

    // runs the actual query
    public void runQuery() {
    showPageBlock = true;
    if(productsToShow == null){
    productsToShow = new list<Product__c>();
    
        try {
            //products = Database.query(soql+ ' order by ' + sortField + ' ' + sortDir);
            ProductsToShow = Database.Query(soql); 
            if(products.size() == 0){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'No Products found for this Criteria');
                ApexPages.addMessage(myMsg);  
                showPageBlock = false;
             }  
        } catch (Exception e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
          }
        totalSize = products.size();
        if((counter+limitSize) <= totalSize){
            for(Integer i=0;i<limitSize;i++){
                productsToShow.add(products.get(i));
            }
        }}else {
            for(Integer i=0;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }
        }
     
    }

    // runs the search with parameters passed via Javascript
    public PageReference runSearch() {
    
        String productType = Apexpages.currentPage().getParameters().get('productType'); 
        String imageUrl = Apexpages.currentPage().getParameters().get('imageUrl');  
        String metal = Apexpages.currentPage().getParameters().get('metal');
        String collectionName = Apexpages.currentPage().getParameters().get('collectionName');
        String stoneType = Apexpages.currentPage().getParameters().get('stoneType');
        String semiPrecious = Apexpages.currentPage().getParameters().get('semiPrecious');
        String stoneOther = Apexpages.currentPage().getParameters().get('stoneOther');
        String centerOther = Apexpages.currentPage().getParameters().get('centerOther');
        String stoneShape = Apexpages.currentPage().getParameters().get('stoneShape');
        String stoneWeight = Apexpages.currentPage().getParameters().get('stoneWeight');
        String centerFromColor = Apexpages.currentPage().getParameters().get('centerFromColor');
        //String centerToColor = Apexpages.currentPage().getParameters().get('centerToColor');
        String clarityCenterFrom = Apexpages.currentPage().getParameters().get('clarityCenterFrom');
        //String clarityCenterTo = Apexpages.currentPage().getParameters().get('clarityCenterTo');
        String certificateType = Apexpages.currentPage().getParameters().get('certificateType');
        String fromTagPrice = Apexpages.currentPage().getParameters().get('fromTagPrice');
        String toTagPrice = Apexpages.currentPage().getParameters().get('toTagPrice');
       
        
        soql = 'select Name,Product_Type__c,Tag_Price__c,Photo__c,Image__C,ImageUrl__c,Stock__c,PictureUpload__c,Metal__c,Collection_Name__c,Centre_Stone_Weight__c,Clarity__c,Certificate_Type__c,Stone_Type_From_Stone_Detail__c,Stone_Shape_From_Stone_Detail__c,Color_Center_From_From_Stone_Details__c,Color_Center_To_From_Stone_Details__c,Certificate_Type_From_Stone_Details__c,Clarity_Center_From_From_Stone_Details__c,Clarity_Center_To_From_Stone_Details__c,Stone_Weight_From_Stone_Details__c,Semi_Precious_From_Stone_Details__c,Stone_Other_From_Stone_Details__c,Center_Other_From_Stone_Details__c from Product__c Where Name != null';
       
        if (!productType.equals(''))
            soql += ' and Product_Type__c LIKE \''+String.escapeSingleQuotes(productType)+'%\'';
      
        if (!imageUrl.equals(''))
            soql += ' and ImageUrl__c LIKE \''+String.escapeSingleQuotes(imageUrl)+'%\''; 
        
        if (!metal.equals(''))
            soql += ' and Metal__c LIKE \''+String.escapeSingleQuotes(metal)+'%\'';
        
        if (!collectionName.equals(''))
            soql += ' and Collection_Name__c LIKE \''+String.escapeSingleQuotes(collectionName)+'%\''; 
        
        if (!stoneWeight.equals(''))
            soql += ' and Stone_Weight_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneWeight)+'\')';
        
        if (!centerFromColor.equals(''))
            soql += ' and Color_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerFromColor)+'\')';  
        /*
        if (!centerToColor.equals(''))
            soql += ' and Color_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerToColor)+'\')';
        */
        if (!clarityCenterFrom.equals(''))
            soql += ' and Clarity_Center_From_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterFrom)+'\')';
        /*       
        if (!clarityCenterTo.equals(''))
            soql += ' and Clarity_Center_To_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(clarityCenterTo)+'\')';
        */
        if (!certificateType.equals(''))
            soql += ' and Certificate_Type_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(certificateType)+'\')';
        
        if (!fromTagPrice.equals(''))
            soql += ' and Tag_Price__c >= '+String.escapeSingleQuotes(fromTagPrice)+'';
            
        if (!toTagPrice.equals(''))
            soql += ' and Tag_Price__c <= '+String.escapeSingleQuotes(toTagPrice)+'';
        
        if (!stoneType.equals(''))
            soql += ' and Stone_Type_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneType)+'\')';  
            
        if (!semiPrecious.equals(''))
            soql += ' and Semi_Precious_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(semiPrecious)+'\')';
        
        if (!stoneOther.equals(''))
            soql += ' and Stone_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(stoneOther)+'\')';
            
        if (!centerOther.equals(''))
            soql += ' and Center_Other_From_Stone_Details__c INCLUDES (\''+String.escapeSingleQuotes(centerOther)+'\')';  
        
        
        if (!stoneShape.equals(''))
            soql += ' and Stone_Shape_From_Stone_Detail__c INCLUDES (\''+String.escapeSingleQuotes(stoneShape)+'\')';
            
        // run the query again
        runQuery();

        return null;
      }
      
    public List<String> listProductTypes{
    get {
        if (listProductTypes == null) {
            listProductTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Product_Type__c.getDescribe();
            
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listProductTypes.add(f.getLabel());
         }
         return listProductTypes;          
         }
    set;
    }
    
    public List<String> listMetal{
    get {
        if (listMetal == null) {
            listMetal = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Metal__c.getDescribe();

            for (Schema.PicklistEntry f : field.getPicklistValues())
                listMetal.add(f.getLabel());
            
        }
        return listMetal;          
    }
    set;
    }
    
    public List<String> listCollectionTypes{
    get {
        if (listCollectionTypes == null) {
            listCollectionTypes = new List<String>();
            Schema.DescribeFieldResult field = Product__c.Collection_Name__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
              listCollectionTypes.add(f.getLabel());
        }
        return listCollectionTypes;          
    }
    set;
    }
    
    public List<String> listStoneTypes{
    get {
        if (listStoneTypes == null) {
            listStoneTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneTypes.add(f.getLabel());
    
        }
      return listStoneTypes;          
    }
    set;
    }
    
    
    
    public List<String> listStoneShapes{
    get {
        if (listStoneShapes == null) {
            listStoneShapes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Stone_Shape_Center__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listStoneShapes.add(f.getLabel());
    
        }
        return listStoneShapes;          
    }
    set;
    }
   
    
    public List<String> listCenterFromColors{
    get {
        if (listCenterFromColors == null) {
            listCenterFromColors = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Color_Centre_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromColors.add(f.getLabel());
    
        }
        return listCenterFromColors;          
    }
    set;
    }
   
    
    public List<String> listCenterFromClarity{
    get {
        if (listCenterFromClarity == null) {
            listCenterFromClarity = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Clarity_Center_From__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCenterFromClarity.add(f.getLabel());
        }
        return listCenterFromClarity;          
    }
    set;
    }
  
    public List<String> listCertificateTypes{
    get {
        if (listCertificateTypes == null) {
            listCertificateTypes = new List<String>();
            Schema.DescribeFieldResult field = Stone_Details__c.Certificate_Type__c.getDescribe();
    
            for (Schema.PicklistEntry f : field.getPicklistValues())
                listCertificateTypes.add(f.getLabel());
        }
        return listCertificateTypes;          
    }
    set;
    }
    
    public void beginning(){
   
        productsToShow.clear();
        counter=0;
        if((counter + limitSize) <= totalSize){
       
            for(Integer i=0;i<limitSize;i++){
                productsToShow.add(products.get(i));
            }   
           
        } else{
       
            for(Integer i=0;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }       
           
        }
    }
    
    public void next(){
   
        productsToShow.clear();
        counter=counter+limitSize;
       
        if((counter+limitSize) <= totalSize){
            for(Integer i=counter;i<(counter+limitSize);i++){
                productsToShow.add(products.get(i));
            }
        } else{
            for(Integer i=counter;i<totalSize;i++){
                productsToShow.add(products.get(i));
            }
        }
    }
   
    public void previous(){
    
        productsToShow.clear();
    
        counter=counter-limitSize;       
       
        for(Integer i=counter;i<(counter+limitSize); i++){
            productsToShow.add(products.get(i));
        }
    }
    
    public void last (){
   
        productsToShow.clear();
       
        if(math.mod(totalSize , limitSize) == 0){
            counter = limitSize * ((totalSize/limitSize)-1);
        } else if (math.mod(totalSize , limitSize) != 0){
            counter = limitSize * ((totalSize/limitSize));
        }
       
        for(Integer i=counter-1;i<totalSize-1;i++){
                productsToShow.add(products.get(i));
        }
       
    }
    
    public Boolean getDisableNext(){
   
        if((counter + limitSize) >= totalSize )
            return true ;
        else
            return false ;
    }
    
    public Boolean getDisablePrevious(){
   
        if(counter == 0)
            return true ;
        else
            return false ;
    } 
}