本文整理汇总了PHP中Mage_Core_Controller_Front_Action类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Controller_Front_Action类的具体用法?PHP Mage_Core_Controller_Front_Action怎么用?PHP Mage_Core_Controller_Front_Action使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Controller_Front_Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _resuscitateCartItems
/**
* 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;
}
示例2: renderPage
/**
* 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;
}
示例3: initProductLayout
/**
* 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;
}
示例4: process
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();
}
}
示例5: preDispatch
/**
* 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;
}
}
}
示例6: preDispatch
/**
* 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');
}
}
示例7: preDispatch
/**
* 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;
}
示例8: _prepareLayout
protected function _prepareLayout()
{
if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle($title);
}
return parent::_prepareLayout();
}
示例9: preDispatch
/**
* 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);
}
}
示例10: preDispatch
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
}
}
示例11: preDispatch
/**
* 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);
}
}
示例12: paymentAction
/**
* 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');
}
}
示例13: loadLayout
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;
}
示例14: addActionLayoutHandles
public function addActionLayoutHandles()
{
parent::addActionLayoutHandles();
$layout = $this->getLayout();
$layout->getUpdate()->addHandle('checkout_onepage_success');
return $this;
}
示例15: addActionLayoutHandles
/**
* 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;
}