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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Advanced Search on Ecommerce module


Go to End


2 Posts   1337 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, 99 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'));
}