Exemplo n.º 1
0
 /**
  * Re-añade los productos comprados a carrito nuevamente
  *
  * @param Mage_Sales_Model_Order $order
  * @return $this
  */
 protected function _resuscitateCartItems(Mage_Sales_Model_Order $order, Mage_Core_Controller_Front_Action $action = null)
 {
     foreach ($order->getItemsCollection() as $orderItem) {
         try {
             $this->getCart()->addOrderItem($orderItem);
         } catch (Mage_Core_Exception $e) {
             /** @var Mage_Checkout_Model_Session $session */
             $session = Mage::getSingleton('checkout/session');
             if ($session->getUseNotice(true)) {
                 $session->addNotice($e->getMessage());
             } else {
                 $session->addError($e->getMessage());
             }
             if ($action) {
                 $action->setRedirectWithCookieCheck('checkout/cart');
             }
         } catch (Exception $e) {
             /** @var Mage_Checkout_Model_Session $session */
             $session = Mage::getSingleton('checkout/session');
             $session->addNotice($e->getMessage());
             $session->addException($e, Mage::helper('checkout')->__('Cannot add the item to shopping cart.'));
             if ($action) {
                 $action->setRedirectWithCookieCheck('checkout/cart');
             }
         }
     }
     $this->getCart()->save();
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Renders CMS page
  *
  * Call from controller action
  *
  * @param Mage_Core_Controller_Front_Action $action
  * @param integer $pageId
  * @return boolean
  */
 public function renderPage(Mage_Core_Controller_Front_Action $action, $identifier = null)
 {
     $page = Mage::getModel('blog/post');
     if (!is_null($identifier) && $identifier !== $page->getId()) {
         $page->setStoreId(Mage::app()->getStore()->getId());
         if (!$page->load($identifier)) {
             return false;
         }
     }
     if (!$page->getId()) {
         return false;
     }
     if ($page->getStatus() == 2) {
         return false;
     }
     $page_title = Mage::getSingleton('blog/post')->load($identifier)->getTitle();
     $blog_title = Mage::getStoreConfig('blog/blog/title') . " - ";
     $action->loadLayout();
     if ($storage = Mage::getSingleton('customer/session')) {
         $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
     }
     /*
      if (Mage::getStoreConfig('blog/rss/enable'))
      {
      Mage::helper('blog')->addRss($action->getLayout()->getBlock('head'), Mage::getUrl(Mage::getStoreConfig('blog/blog/route')) . "rss");
      }
     */
     $action->getLayout()->getBlock('head')->setTitle($blog_title . $page_title);
     //$action->getLayout()->getBlock('root')->setTemplate(Mage::getStoreConfig('blog/blog/layout'));
     $action->renderLayout();
     return true;
 }
Exemplo n.º 3
0
 /**
  * Inits layout for viewing product page
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Core_Controller_Front_Action $controller
  *
  * @return Mage_Catalog_Helper_Product_View
  */
 public function initProductLayout($product, $controller)
 {
     $design = Mage::getSingleton('catalog/design');
     $settings = $design->getDesignSettings($product);
     if ($settings->getCustomDesign()) {
         $design->applyCustomDesign($settings->getCustomDesign());
     }
     $update = $controller->getLayout()->getUpdate();
     $update->addHandle('default');
     $controller->addActionLayoutHandles();
     /* START OF CODE FOR CUSTOMIZATION OF PREMIUM PACKAGING */
     /*
     $premium = false;
     
     $catIds = $product->getCategoryIds();
     
     $premium	=	Mage::getModel('packaging/packaging')->bool_isPremiumPackaging($catIds, true);
     
     if($premium) {
     	$update->addHandle('PRODUCT_TYPE_PREMIUM');
     	$update->addHandle('PRODUCT_' . $product->getId());
     } else {
     */
     $update->addHandle('PRODUCT_TYPE_' . $product->getTypeId());
     $update->addHandle('PRODUCT_' . $product->getId());
     /*
     }
     */
     /* END OF CODE FOR CUSTOMIZATION OF PREMIUM PACKAGING */
     $controller->loadLayoutUpdates();
     // Apply custom layout update once layout is loaded
     $layoutUpdates = $settings->getLayoutUpdates();
     if ($layoutUpdates) {
         if (is_array($layoutUpdates)) {
             foreach ($layoutUpdates as $layoutUpdate) {
                 $update->addUpdate($layoutUpdate);
             }
         }
     }
     $controller->generateLayoutXml()->generateLayoutBlocks();
     // Apply custom layout (page) template once the blocks are generated
     if ($settings->getPageLayout()) {
         $controller->getLayout()->helper('page/layout')->applyTemplate($settings->getPageLayout());
     }
     $currentCategory = Mage::registry('current_category');
     $root = $controller->getLayout()->getBlock('root');
     if ($root) {
         $controllerClass = $controller->getFullActionName();
         if ($controllerClass != 'catalog-product-view') {
             $root->addBodyClass('catalog-product-view');
         }
         $root->addBodyClass('product-' . $product->getUrlKey());
         if ($currentCategory instanceof Mage_Catalog_Model_Category) {
             $root->addBodyClass('categorypath-' . $currentCategory->getUrlPath())->addBodyClass('category-' . $currentCategory->getUrlKey());
         }
     }
     return $this;
 }
Exemplo n.º 4
0
 public function process(Mage_Core_Controller_Front_Action $controller)
 {
     $request = $controller->getRequest();
     if ($request->isXmlHttpRequest() || !$request->isGet() || strpos($request->getHeader('accept'), 'text/html') === false) {
         return;
     } else {
         $searchText = $this->getSearchQuery($controller->getRequest());
         $message = Mage::helper('searchindex')->__('The page you requested was not found, but we have searched for relevant content.');
         Mage::getSingleton('core/session')->addNotice($message);
         Mage::getSingleton('core/session')->setData('route404', $message);
         $url = Mage::getUrl('catalogsearch/result', array('_query' => array('q' => $searchText)));
         $controller->getResponse()->clearHeaders()->setRedirect($url)->sendResponse();
     }
 }
Exemplo n.º 5
0
 /**
  * Use 'admin' store and prevent the session from starting
  *
  * @return Mage_Api_Controller_Action
  */
 public function preDispatch()
 {
     Mage::app()->setCurrentStore('admin');
     $this->setFlag('', self::FLAG_NO_START_SESSION, 1);
     parent::preDispatch();
     return $this;
 }
 protected function _prepareLayout()
 {
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         $headBlock->setTitle($title);
     }
     return parent::_prepareLayout();
 }
Exemplo n.º 7
0
 /**
  * Checking if user is logged in or not
  * If not logged in then redirect to customer login
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->customerSession()->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
     }
 }
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
         $this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
     }
 }
Exemplo n.º 9
0
 /**
  * Action predispatch
  *
  * Check customer authentication for some actions
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
     }
 }
Exemplo n.º 10
0
 /**
  * Show orderPlaceRedirect page which contains the Moneybookers iframe.
  */
 public function paymentAction()
 {
     try {
         $session = $this->_getCheckout();
         $order = $this->placeOrder();
         $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('moneybookers')->__('The customer was redirected to Moneybookers.'));
         $order->save();
         $this->_order = $order;
         $session->setLastRealOrderId($order->getIncrementId());
         $session->setMoneybookersQuoteId($session->getQuoteId());
         $session->setMoneybookersRealOrderId($session->getLastRealOrderId());
         $session->getQuote()->setIsActive(false)->save();
         $session->clear();
         $this->loadLayout();
         //load layout of moneybookers
         //            $update = $this->getLayout()->getUpdate();
         //            $update->addHandle('default');
         //            $this->addActionLayoutHandles();
         //            $update->addHandle('moneybookers_processing_payment');
         //            $this->loadLayoutUpdates();
         //            $this->generateLayoutXml();
         //            $this->generateLayoutBlocks();
         //            $this->_isLayoutLoaded = true;
         //render layout
         $this->renderLayout();
     } catch (Exception $e) {
         die($e->getMessage());
         Mage::logException($e);
         parent::_redirect('checkout/cart');
     }
 }
Exemplo n.º 11
0
 public function loadLayout($handles = null, $generateBlocks = true, $generateXml = true)
 {
     $original_results = parent::loadLayout($handles, $generateBlocks, $generateXml);
     $handles = Mage::getSingleton('core/layout')->getUpdate()->getHandles();
     echo "<strong >Handles Generated For This Request : ", implode(",", $handles), "</strong>";
     return $original_results;
 }
 public function addActionLayoutHandles()
 {
     parent::addActionLayoutHandles();
     $layout = $this->getLayout();
     $layout->getUpdate()->addHandle('checkout_onepage_success');
     return $this;
 }
 /**
  * Make sure the customer is authenticated of necessary
  *
  * @return Mage_Core_Controller_Front_Action | void
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->getRequest()->isDispatched()) {
         return;
     }
     $authenticationRequired = (bool) Mage::getStoreConfig(Solvingmagento_AffiliateProduct_Model_Product_Type::XML_PATH_AUTHENTICATION);
     if ($authenticationRequired) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         if ($customer && $customer->getId()) {
             $validationResult = $customer->validate();
             if (true !== $validationResult && is_array($validationResult)) {
                 foreach ($validationResult as $error) {
                     Mage::getSingleton('core/session')->addError($error);
                 }
                 $this->goBack();
                 $this->setFlag('', self::FLAG_NO_DISPATCH, true);
                 return $this;
             }
             return $this;
         } else {
             Mage::getSingleton('customer/session')->addError($this->helper->__('You must log in to access the partner product'));
             $this->_redirect('customer/account/login');
             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
             return $this;
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Adds an additional layout handle based on view name, since
  * full action handle will always be the same.
  */
 public function addActionLayoutHandles()
 {
     $r = parent::addActionLayoutHandles();
     $update = $this->getLayout()->getUpdate();
     $update->addHandle(strtolower($this->getHandlerActionHandle()));
     return $r;
 }
 /**
  * Predispatch: shoud set layout area
  *
  * @return Mage_Core_Controller_Front_Action
  */
 public function preDispatch()
 {
     try {
         // call the parents class method
         parent::preDispatch();
         // resolve the needed parameters from the requested resource name
         $this->_params = Mage::helper('channel')->resolve($this->getRequest()->getRequestString());
         // return the instance itself
         return $this;
     } catch (Faett_Channel_Exceptions_ResourceNotFoundException $rnfe) {
         // log the exception
         Mage::logException($rnfe);
         // register the error message
         Mage::register(Faett_Channel_Block_NotFound::MESSAGE, $this->_getHelper()->__($rnfe->getKey()));
         // forward to the not found page
         $this->_forward('notFound', 'error', 'channel');
     } catch (Exception $e) {
         // log the exception
         Mage::logException($e);
         // register the error message
         Mage::register(Faett_Channel_Block_InternalServerError::MESSAGE, $e->getMessage());
         // forward to the internal server error page
         $this->_forward('internalServerError', 'error', 'channel');
     }
 }
 /**
  * Prepare menu and handles
  */
 public function addActionLayoutHandles()
 {
     parent::addActionLayoutHandles();
     $update = $this->getLayout()->getUpdate();
     $update->addHandle('open_gallery');
     $update->addHandle('open_gallery_scripts');
 }
Exemplo n.º 17
0
 public function preDispatch()
 {
     $this->setFlag('', self::FLAG_NO_START_SESSION, 1);
     // Do not start standart session
     parent::preDispatch();
     return $this;
 }
Exemplo n.º 18
0
 public function preDispatch()
 {
     if (!Mage::getStoreConfig('lotusbreath_onestepcheckout/general/enabled')) {
         $this->_redirect(Mage::getUrl('checkout/onepage/index'));
     }
     /**
      * Disable some event for optimization
      */
     if (!Mage::getStoreConfig('lotusbreath_onestepcheckout/speedoptimizer/disablerssobserver')) {
         $eventConfig = Mage::getConfig()->getEventConfig('frontend', 'sales_order_save_after');
         if ($eventConfig->observers->notifystock->class == 'rss/observer') {
             $eventConfig->observers->notifystock->type = 'disabled';
         }
         if ($eventConfig->observers->ordernew->class == 'rss/observer') {
             $eventConfig->observers->ordernew->type = 'disabled';
         }
     }
     if (!Mage::getStoreConfig('lotusbreath_onestepcheckout/speedoptimizer/disablevisitorlog')) {
         $eventConfig = Mage::getConfig()->getEventConfig('frontend', 'controller_action_predispatch');
         $eventConfig->observers->log->type = 'disabled';
         $eventConfig = Mage::getConfig()->getEventConfig('frontend', 'controller_action_postdispatch');
         $eventConfig->observers->log->type = 'disabled';
         $eventConfig = Mage::getConfig()->getEventConfig('frontend', 'sales_quote_save_after');
         $eventConfig->observers->log->type = 'disabled';
         $eventConfig = Mage::getConfig()->getEventConfig('frontend', 'checkout_quote_destroy');
         $eventConfig->observers->log->type = 'disabled';
     }
     parent::preDispatch();
     if (!$this->getRequest()->getParam('allow_gift_messages')) {
         $this->getRequest()->setParam('giftmessage', false);
     }
     return $this;
 }
 function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
 {
     parent::__construct($request, $response, $invokeArgs);
     $post = $this->getRequest()->getParams();
     if (isset($post['action']) && isset($post['submodule'])) {
         $json = Mage::helper('core')->jsonDecode($post['values']);
         if (isset($json['parent'])) {
             $url = Mage::helper('ajaxKit')->clearUrl($json['parent']['url']);
             $url_arr = explode('?', $url);
             $url = $url_arr[0];
             if ('product' == $json['parent']['controller'] || 'category' == $json['parent']['controller']) {
                 $oRewrite = Mage::getModel('core/url_rewrite')->setStoreId(Mage::app()->getStore()->getId())->loadByRequestPath($url);
                 if ('product' == $json['parent']['controller']) {
                     Mage::register('current_product', Mage::getModel('catalog/product')->load((int) $oRewrite->getProductId()));
                 } else {
                     Mage::register('current_category', Mage::getModel('catalog/category')->load((int) $oRewrite->getCategoryId()));
                 }
             } elseif ('cms' == $json['parent']['module']) {
                 if ('index' == $json['parent']['controller']) {
                     $pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE);
                     Mage::getSingleton('cms/page')->load($pageId);
                 } else {
                     Mage::getSingleton('cms/page')->load($url, 'identifier');
                 }
             }
             Mage::register('meigee_ajax', $json['parent']);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * @param null $defaultUrl
  * @return Mage_Core_Controller_Varien_Action
  */
 protected function _redirectReferer($defaultUrl = null)
 {
     if ($store = $this->getRequest()->getParam('store')) {
         Mage::app()->setCurrentStore($store);
     }
     return parent::_redirectReferer($defaultUrl);
 }
Exemplo n.º 21
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getStoreConfigFlag('productlist/general_setting/show')) {
         $this->norouteAction();
     }
 }
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->_getSession()->authenticate($this) || !Mage::helper('palorus')->isVaultEnabled()) {
         $this->setFlag('', 'no-dispatch', true);
     }
 }
Exemplo n.º 23
0
 /**
  * require login when access this controller
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->getRequest()->isDispatched()) {
         return;
     }
     // David - Update create user
     if (Mage::helper('usermanagement')->isEnable() && Mage::getSingleton('customer/session')->getCustomerId() && !Mage::helper('usermanagement')->isExistUser()) {
         // Create new user
         Mage::getSingleton('usermanagement/observer')->customerRegister(new Varien_Object(array('customer' => Mage::getSingleton('customer/session')->getCustomer())));
     }
     // David - End update create user
     if (!Mage::helper('usermanagement')->isEnable() || !Mage::helper('usermanagement')->isExistUser()) {
         $this->_redirect('customer/account');
         $this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
         return;
     }
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
     } else {
         $user = Mage::getSingleton('core/session')->getData('usermanagement_user');
         if (!$user || !$user->getId()) {
             $customer = Mage::getSingleton('customer/session')->getCustomer();
             $user = Mage::getModel('usermanagement/user')->load($customer->getId(), 'customer_id');
             Mage::getSingleton('core/session')->setData('usermanagement_user', $user);
         }
     }
 }
Exemplo n.º 24
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::helper('blog')->getEnabled()) {
         $this->_redirectUrl(Mage::helper('core/url')->getHomeUrl());
     }
 }
 /**
  * Action predispatch
  *
  * Check customer authentication for some actions
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('customer/session')->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
     }
 }
Exemplo n.º 26
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
         $this->norouteAction();
     }
 }
Exemplo n.º 27
0
 /**
  * Controller predispatch method to change area for some specific action.
  *
  * @return Mage_Rss_OrderController
  */
 public function preDispatch()
 {
     if ($this->getRequest()->getActionName() == 'new') {
         $this->_currentArea = 'adminhtml';
         Mage::helper('rss')->authAdmin('sales/order');
     }
     return parent::preDispatch();
 }
Exemplo n.º 28
0
 /**
  * Dispatch event before action
  *
  * @return void
  */
 public function preDispatch()
 {
     $this->setFlag('', self::FLAG_NO_START_SESSION, 1);
     $this->setFlag('', self::FLAG_NO_CHECK_INSTALLATION, 1);
     $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, 0);
     $this->setFlag('', self::FLAG_NO_PRE_DISPATCH, 1);
     parent::preDispatch();
 }
Exemplo n.º 29
0
 /**
  * Check authentication
  *
  * Check customer authentication for some actions
  */
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_session = Mage::getSingleton($this->_sessionName);
     if (!$this->_session->authenticate($this)) {
         $this->setFlag('', self::FLAG_NO_DISPATCH, true);
     }
 }
Exemplo n.º 30
0
 public function preDispatch()
 {
     parent::preDispatch();
     if (!Mage::getSingleton('facebook/config')->isEnabled()) {
         $this->norouteAction();
         return;
     }
 }