/** * We save the chosen value for the products per page in the customer's * configuration object here and redirect to the last view. * * @param SS_HTTPRequest $data contains the frameworks form data * @param Form $form not used * @param array $formData contains the modules form data * * @return void * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**> * @since 15.11.2014 */ public function submitSuccess($data, $form, $formData) { $backLink = $this->controller->Link(); $member = SilvercartCustomer::currentUser(); $product = singleton('SilvercartProduct'); $sortableFrontendFields = $product->sortableFrontendFields(); $sortableFrontendFieldValues = array_keys($sortableFrontendFields); $sortOrder = $sortableFrontendFieldValues[$data['SortOrder']]; SilvercartProduct::setDefaultSort($sortOrder); if (!$member) { $member = SilvercartCustomer::createAnonymousCustomer(); } if ($member) { $member->getSilvercartCustomerConfig()->productsPerPage = $data['productsPerPage']; $member->getSilvercartCustomerConfig()->write(); } if (isset($formData['backLink'])) { $backLink = $formData['backLink']; } $this->controller->redirect($backLink, 302); }
/** * chpppopt stands for "CHange Products Per Page Option". * Changes the quantity of products to display in a product lists. * * @param SS_HTTPRequest $request Request * * @return string * * @author Sebastian Diel <*****@*****.**> * @since 27.11.2014 */ public function chpppopt(SS_HTTPRequest $request) { $member = SilvercartCustomer::currentUser(); $newOption = $request->param('ID'); $product = singleton('SilvercartProduct'); $sortableFrontendFields = $product->sortableFrontendFields(); $sortableFrontendFieldValues = array_keys($sortableFrontendFields); if (array_key_exists($newOption, $sortableFrontendFieldValues)) { $sortOrder = $sortableFrontendFieldValues[$newOption]; SilvercartProduct::setDefaultSort($sortOrder); } if ($member instanceof Member && $member->exists()) { $member->getSilvercartCustomerConfig()->productsPerPage = $newOption; $member->getSilvercartCustomerConfig()->write(); } self::setProductsPerPage($newOption); $this->redirect($this->Link()); }
/** * Action to execute a search query * * @param SS_HTTPRequest $request Request to check for product data * @param bool $doRedirect Redirect after setting search settings? * * @return void * * @author Sebastian Diel <*****@*****.**> * @since 30.06.2014 */ public function doSearch(SS_HTTPRequest $request, $doRedirect = true) { $postVars = $request->postVars(); if (!array_key_exists('locale', $postVars) || empty($postVars['locale'])) { $postVars['locale'] = Translatable::default_locale(); } Translatable::set_current_locale($postVars['locale']); i18n::set_locale($postVars['locale']); $quickSearchQuery = trim($postVars['quickSearchQuery']); $searchContext = 'SilvercartProduct'; $searchResultsPage = SilvercartTools::PageByIdentifierCode("SilvercartSearchResultsPage"); $searchQuery = SilvercartSearchQuery::get_by_query(trim(Convert::raw2sql($quickSearchQuery))); $searchQuery->Count++; $searchQuery->write(); SilvercartProduct::setDefaultSort('relevance'); Session::set("searchQuery", $quickSearchQuery); Session::set('searchContext', $searchContext); Session::save(); if ($doRedirect) { $this->owner->redirect($searchResultsPage->RelativeLink()); } }