public function resultAction() { $this->loadLayout(); try { AO::getSingleton('catalogsearch/advanced')->addFilters($this->getRequest()->getQuery()); } catch (Mage_Core_Exception $e) { AO::getSingleton('catalogsearch/session')->addError($e->getMessage()); $this->_redirectError(AO::getURL('*/*/')); } $this->_initLayoutMessages('catalog/session'); $this->renderLayout(); }
public function sendmailAction() { $product = $this->_initProduct(); $sendToFriendModel = $this->_initSendToFriendModel(); $data = $this->getRequest()->getPost(); if (!$product || !$product->isVisibleInCatalog() || !$data) { $this->_forward('noRoute'); return; } $categoryId = $this->getRequest()->getParam('cat_id', null); if ($categoryId && ($category = AO::getModel('catalog/category')->load($categoryId))) { AO::register('current_category', $category); } $sendToFriendModel->setSender($this->getRequest()->getPost('sender')); $sendToFriendModel->setRecipients($this->getRequest()->getPost('recipients')); $sendToFriendModel->setIp(AO::getSingleton('log/visitor')->getRemoteAddr()); $sendToFriendModel->setProduct($product); try { $validateRes = $sendToFriendModel->validate(); if (true === $validateRes) { $sendToFriendModel->send(); AO::getSingleton('catalog/session')->addSuccess($this->__('Link to a friend was sent.')); $this->_redirectSuccess($product->getProductUrl()); return; } else { AO::getSingleton('catalog/session')->setFormData($data); if (is_array($validateRes)) { foreach ($validateRes as $errorMessage) { AO::getSingleton('catalog/session')->addError($errorMessage); } } else { AO::getSingleton('catalog/session')->addError($this->__('Some problems with data.')); } } } catch (Mage_Core_Exception $e) { AO::getSingleton('catalog/session')->addError($e->getMessage()); } catch (Exception $e) { AO::getSingleton('catalog/session')->addException($e, $this->__('Some emails was not sent')); } $this->_redirectError(AO::getURL('*/*/send', array('id' => $product->getId()))); }