isLoggedIn()) { Mage::getModel('customer/session')->setBeforeAuthUrl( Mage::getModel('core/url')->getUrl('custom-product') ); $this->_redirect('customer/account/login/'); return false; } return true; } public function indexAction() { if (!$this->_initAction()) { return $this; } $layout = $this->loadLayout()->getLayout(); $layout->getBlock('head')->setTitle($this->__('Individual Order')); $this->renderLayout(); return $this; } public function sendAction() { if (!$this->_initAction()) { return $this; } try { $this->_sendEMail(); Mage::getModel('core/session')->addSuccess($this->__( 'Your inquiry was submitted and will be responded to as' . ' soon as possible. Thank you for contacting us.' )); } catch (Exception $e) { Mage::getModel('core/session')->addError($this->__( 'Unable to submit your request. Please, try again later' )); } $this->_redirect('*/index/index'); return $this; } protected function _sendEMail() { if (!$this->getRequest()->getParam('content')) { throw new Exception('Empty content'); } if (!$this->getRequest()->getParam('telephone')) { throw new Exception('Empty telephone'); } $content = $this->loadLayout()->getLayout()->getBlock('custom.product.email')->toHtml(); $email = Mage::getStoreConfig('trans_email/ident_sales/email'); if (!$email) { throw new Exception('Undefined e-mail'); } $headers = 'From: ' . Mage::getModel('customer/session')->getCustomer()->getEmail() . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n"; if (!mail( $email, $this->__('Замовлення Індивідуального Продукта'), $content, $headers )) { throw new Exception('Internal error'); } return $this; } }