Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Advanced Search on Ecommerce module


Reply


2 Posts   1104 Views

Avatar
SSadmin

Community Member, 90 Posts

3 September 2010 at 11:44am

Hey, folks,

I wonder is there a way that we could decorate the generic Search function to apply search onto ecommerce module.
For instance, could search by Category, Artist, and even additonal fields that developer cutomized in their product.php.
Any suggestions or ideas for achieving that?!
Thanks in advanced.

Avatar
merrick_sd

Community Member, 97 Posts

5 February 2011 at 12:17am

I'm wondering that too.
I want to search the product InternalItemID (productcode)

SS 2.3.4
mysite > page.php

   /**
    * Site search form
    */
   function SearchForm() {
      $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
      $fields = new FieldSet(
       new TextField("Search", "", $searchText)
       );
      $actions = new FieldSet(
       new FormAction('results', 'Search')
       );

       return new SearchForm($this, "SearchForm", $fields, $actions);
   }
   
   /**
    * Process and render search results
    */
   function results($data, $form){
       $data = array(
       'Results' => $form->getResults(),
       'Query' => $form->getSearchQuery(),
       'Title' => 'Search Results'
       );

       return $this->customise($data)->renderWith(array('Page_results', 'Page'));
   }