Subesh Pokhrel

Magento Developers Blog

Adding CSS Class Name to My Account Link (Anchor Tag) in Magento Through XML Layout

At the first instance I thought WTH! must be pretty simple, add params in XML layout and ”Voila!”. But later I found that it was not simpler as I thought. I had to get into the addLink method for sometime (1/2hr) and finally I came up with correct structure of XML layout. At the end it again seemed simple though, but it needed a healthy effort. Here’s the XML structure of layout from customer.xml where you add class to My Account link. [source language=”xml”] <!– customer.xml–> <reference name="top.links"> <action method="addLink" translate="label title" module="customer"> <label>My Account</label> <url helper="customer/getAccountUrl"/> <title>My Account</title> <prepare/> <urlParams/> <class/> <position>10</position> <aParams> <class>my-class-name</class> </aParams> </action> </reference> <!– customer.xml–> [/source] One notable thing in the structure above is the aParams which is responsible for adding the class to the Anchor tag, not the List tag. Hope this helps someone! Happy Coding.

Working With Ajax and JSON Objects in Magento [Case: Ajax Powered Login Functionality]

Previously I have written about Working With Ajax in Magento. And after a huge response I received from that post I was compelled to write more on implementing Ajax in Magento. And this time I want to say additionally about handling JSON (JavaScript Object Notation) along with Ajax, within the Magento enviornment. JSON Objects and Ajax can be very helpful technique to get the work done. You can learn about JSON from Here. I will try to describe this issue by taking a case of changing the Magento’s login functionality to a Ajax powered login functionality. So after this you will be able to implement a login function in a pop-up div in any page, unlike the default Magento’s seperate login page. I will leave the pop-up div part to you and get started with the real business (AJAX and JSON). Presuming that you will use Mini-Login form. Here is how you proceed.
  1. Change Submit type button to Button type button.
  2. Register OnClick Javascript event of that button and its Handler
  3. In the Handler function call Ajax Request for login
  4. Show Error Message or redirect to customer Dashboard
Your mini.login.phtml should be like this [source language=”html”] <form action="<?php //echo $this->getPostActionUrl() ?>" id="mini-login-form" method="post"> <fieldset> <p><label><?php echo $this->__(‘Email’) ?>:</label> <input name="login[username]" class="input-text" /></p> <p><label><?php echo $this->__(‘Password’) ?>:</label> <input name="login[password]" class="input-text" /></p> <p><input type="button" onClick="handlerFunction()" value="<?php echo $this->__(‘Login’) ?>" /></p> </fieldset> </form> <script type="text/javascript"> <!– function handlerFunction(){ // Write These codes only after form Validation // Making Ajax Request var request = new Ajax.Request( //Defining Ajax Request URL, We are calling custom Controller Ns_Mylogin_AccountController Class (Defined Below) ‘<?php echo $this->getUrl("mylogin/account/loginPost") ?>’, { method: ‘post’, onComplete: function(transport){ // Defining Complete Callback Function // Getting Ajax Response Text Which is JSON Object var jsonResponse=transport.responseText; //Checking JSON Objects property and performing related action // You will understand the response Text format after going through the controller description (Below) if(jsonResponse.error){ alert("Error Occured"); return false; } else{ window.location.href=jsonResponse.url; } }, parameters: Form.serialize($("mini-login-form")) // Seriallizing the form input values } ); } //–> </script> [/source] Please see inline comments for better understanding. Now our next set should be setting up our custom controller. I’ll not get into details of setting up modules and all but directly to our controller class Ns_Mylogin_AccountController. What I’ve done is just taken the core’s loginPostAction function of Mage_Customer_AccountController and added some codes there. Please see there is a comment on each line added apart from the default Magento’s core code. [source language=”php”] <?php require_once("Mage/Customer/controllers/AccountController.php"); class Ns_Mylogin_AccountController extends Mage_Customer_AccountController{ /** * Login post action * @return JSON Object */ public function loginPostAction() { // Added Line #1 $result["error"]=0; $session = $this->_getSession(); if ($this->getRequest()->isPost()) { $login = $this->getRequest()->getPost(‘login’); if (!empty($login[‘username’]) &amp;&amp; !empty($login[‘password’])) { try { $session->login($login[‘username’], $login[‘password’]); if ($session->getCustomer()->getIsJustConfirmed()) { $this->_welcomeCustomer($session->getCustomer(), true); } } catch (Mage_Core_Exception $e) { switch ($e->getCode()) { case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED: //Added Line #2 $result["error"]=1; $message = Mage::helper(‘customer’)->__(‘This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.’, Mage::helper(‘customer’)->getEmailConfirmationUrl($login[‘username’])); break; case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD: //Added Line #3 $result["error"]=1; $message = $e->getMessage(); break; default: //Added Line #4 $result["error"]=1; $message = $e->getMessage(); } $session->addError($message); $session->setUsername($login[‘username’]); } catch (Exception $e) { // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password } } else { //Added Line #5 $result["error"]=1; $session->addError($this->__(‘Login and password are required’)); //Added Line #6 $this->getResponse()->setBody(Mage::helper(‘core’)->jsonEncode($result)); } } //Added Line #7 $result["url"]=$this->_loginPostRedirect(); //Added Line #8 $this->getResponse()->setBody(Mage::helper(‘core’)->jsonEncode($result)); } [/source] What I’ve done is added an array $result that will hold value if there is error or not while processing the user’s request. If there is error that array will hold $result[‘error’]=1 else it will be as initiallized in Added Line #1. From Added Line #2 through Added Line #5, we have various condition to check for error and set our $result variable. On Added Line #7 we have called another function (which we we rewrite as well) that will give us the url location identifying which location should be redirect after successful login. The implementation of function is given below. Finally in Added Line #8 and Line #6 we have encoded our $result array into JSON format and send as the response. For visuallization our $result array will be one of the following.
  1. Case (No Error) : $result[“error”]=0; $result[“url”]=”SOME Redirect URL”
  2. Case (Error) : $result[“error”]=1;
This JSON encoded response will be then used by the ajax call back function defined and perform related action. Here’s the _loginPostRedirect() function which I mentioned (Added Line #7). [source language=”php”] /** * Define target URL and redirect customer after logging in */ protected function _loginPostRedirect() { $session = $this->_getSession(); if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl() ) { // Set default URL to redirect customer to $session->setBeforeAuthUrl(Mage::helper(‘customer’)->getAccountUrl()); // Redirect customer to the last page visited after logging in if ($session->isLoggedIn()) { if (!Mage::getStoreConfigFlag(‘customer/startup/redirect_dashboard’)) { if ($referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME)) { $referer = Mage::helper(‘core’)->urlDecode($referer); if ($this->_isUrlInternal($referer)) { $session->setBeforeAuthUrl($referer); } } } else if ($session->getAfterAuthUrl()) { $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); } } else { $session->setBeforeAuthUrl(Mage::helper(‘customer’)->getLoginUrl()); } } else if ($session->getBeforeAuthUrl() == Mage::helper(‘customer’)->getLogoutUrl()) { $session->setBeforeAuthUrl(Mage::helper(‘customer’)->getDashboardUrl()); } else { if (!$session->getAfterAuthUrl()) { $session->setAfterAuthUrl($session->getBeforeAuthUrl()); } if ($session->isLoggedIn()) { $session->setBeforeAuthUrl($session->getAfterAuthUrl(true)); } } // Changed Here return $session->getBeforeAuthUrl(true); } [/source] You can download the code From Here. Hope it helps! Happy Coding.

Displaying Currency Code After the Price Value in Magento

I had a time to research on Magento’s currency format and its display on Magento webshop. I then came across a block where I could change the format of currency display, in this case I am talking about moving the currency symbol to the right of the price value. In other words I found a way to show $10.00 as 10.00$. Notice the $ (Dollar) sign moving at the right of the price value. Here’s a description of how this can be achievable. The basic idea is to rewrite Mage_Core_Model_Locale class’s currency function and add additional code. First you must write a rewrite code in your module’s config.xml. [source language=”xml”] <core> <rewrite> <locale>Namespace_Module_Model_Locale</locale> </rewrite> </core> [/source] Then in Namespace_Module_Model_Locale class you can add the following code. [source language=”php”] class Namespace_Module_Model_Locale extends Mage_Core_Model_Locale{ /* * Code: subesh.com.np */ public function currency($currency) { Varien_Profiler::start(‘locale/currency’); if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) { try { $currencyObject = new Zend_Currency($currency, $this->getLocale()); // Additionally Added Code // The options array’s position key has other values as well. // Zend_Currency::STANDARD // Zend_Currency::RIGHT // Zend_Currency::LEFT $options = array( ‘position’ => Zend_Currency::RIGHT ); $currencyObject->setFormat($options); // END Additionally Added Code } catch (Exception $e) { $currencyObject = new Zend_Currency($this->getCurrency(), $this->getLocale()); $options = array( ‘name’ => $currency, ‘currency’ => $currency, ‘symbol’ => $currency ); $currencyObject->setFormat($options); } self::$_currencyCache[$this->getLocaleCode()][$currency] = $currencyObject; } Varien_Profiler::stop(‘locale/currency’); return self::$_currencyCache[$this->getLocaleCode()][$currency]; } } [/source] You can see the comment of the code above for more detail understanding. P.S: Be informed that you need to change the Class Name you are about to create on the basis of your Namespace and Module name.

Magento: Setting Up a Default Shipping Method on Cart Page

I recently came to a situation where I need to show a shipping price amount on cart before selecting the shipping address from the checkout page. Basically shipping price is shown after the user has added the shipping address and selected the shipping method. So to show shipping price on cart page load, I needed to find out the following. Shipping Address (Actually only country_id will work) Shipping Method (Set to Flatrate in the code below) So what I did was first check if the user has already specified the shipping address (when user have added the shipping address in the checkout page and navigated back to cart page). If the shipping address is not present then I checked if the user is logged in and checked for default shipping address of the customer and used its country_id (if present), but if the user is not logged in or default shipping address is not present then I set the shipping address (country_id) to some country (NL).After setting the country I then set the shipping method and then saved the quote so that the prices are calculated.Here’s the snippet. [source language=”php”] /*** Setting Default Shipping Method * Checking If Quote Already Has Address Or Not * - If Yes then leave as it is * - Else check if Customer has default Shipping Address or Not * – Yes then get Default Shipping Address and set Shipping Method * – No Set Default Shipping address to NL*/ if(!Mage::getSingleton(‘checkout/type_onepage’)->getQuote()->getShippingAddress()->getCountryId()){ $customerSession=Mage::getSingleton("customer/session"); if($customerSession->isLoggedIn()){ $customerAddress=$customerSession->getCustomer()->getDefaultShippingAddress(); if($customerAddress->getId()){ $customerCountry=$customerAddress->getCountryId(); $shipping = Mage::getSingleton(‘checkout/type_onepage’)->getQuote()->getShippingAddress()->setCountryId($customerCountry)->setShippingMethod(‘flatrate_flatrate’)->save(); }else{ $shipping = Mage::getSingleton(‘checkout/type_onepage’)->getQuote()->getShippingAddress()->setCountryId(‘NL’)->setShippingMethod(‘flatrate_flatrate’)->save(); } } } [/source] Cheers! [UPDATE] The original solution seems to show some issue. Thanks to the great reader of this blog the “perfect” solution for this case can be found in comments. As always new and better solutions are always welcome.

Worldcup: German Coach to File a Case Against Spanish in FIFA

Normally, I post tech stuff in my blog, but can’t get away from football world cup fever. And my friend broke a news that German coach will file a case against Spanish, claiming that Germans should have also got the ball during the play at semis, because they were also playing the same game. LOL! Can’t wait for the trial sessions.. HAHAHAHAHAHA Go SPAIN!

Magento: Creating Ajax Updated Tabs in Frontend, Like Product Management Tabs of Backend

Magento’s Product Management GUI in back-end has Tabbed Navigation. There are two types of Tabs implemented there. One type of Tab is normal tab, loading content on page load while other type of tab has its content loaded by “Ajax”. Another interesting thing to note is that once the Ajax loaded tab’s content is loaded it will not “recall” Ajax to load its content, rather earlier loaded tab content is show. If are “confused” then just see how the “Categories” tab of the Product Management works. I successfully used the same “behavior” of tabbed navigation in “front-end”, was easy at the end (always with Magento, when you get it), but I was struggling at the start. So, like my other posts, to share here’s how I used the same type of tab in Magento’s Front-end. First thing is add the Tab’s Java-script file. You can either include by layout or in PHTML file. If you want to do from layout then, [source language=”xml”] <reference name="head"> <action method="addJs"><script>mage/adminhtml/tabs.js</script></action> </reference> [/source] Next thing is to create Tab’s Menu inside UL & LI. Here’s the structure. (Self Explanatory) [source language=”html”] <!– TAB MENU STRUCTURE –> <ul id="page_tabs"> <!– NORMAL TAB –> <li> <a id="normaltab" name="normaltab" class="tab-item-link" href="#"> NORMAL TAB </a> <!– NOTE: class has to be tab-item-link–> <div id="normaltab_content"> Normal Tab HTML</div> <!– NOTE: See the id of this div content it has id equal to its anchor’s (<a>) id + Underscore + content –> </li> <!– NORMAL TAB END–> <!– AJAX LOADED TAB –> <li> <a id="ajaxtab" name="ajaxtab" class="tab-item-link ajax notloaded" href="http://example.com/magento/module/controller/action"> AJAX TAB </a> <!– NOTE 1: class has to be tab-item-link ajax notloaded –> <!– NOTE 2: Since this is Ajax Loaded Tab its Anchor should have href value = SOME URL –> <div id="ajaxtab_content"></div> <!– NOTE 1: See the id of this div content it has id equal to its anchor’s (<a>) id + Underscore + content –> <!– NOTE 2: Since its innerHTML will be loaded by by Ajax you can set its innerHTML "blank" –> </li> <!– AJAX LOADED TAB END –> </ul> <!– TAB MENU STRUCTURE END –> <!– TAB CONTENT CONTAINER DIV–> <div id="tabcontainer"></div> <!– TAB CONTENT CONTAINER DIV–> [/source] Now its the time to use the Tabs JS included, like below. [source language=”js”] <script> // Form Key Required for POST AJAX Method var FORM_KEY="<?php echo Mage::getSingleton(‘core/session’)->getFormKey() ?>"; // Set this to false, Guess used for some other purpose in backend, not really required in frontend. var varienGlobalEvents=false; // Initiallizing Varien Tabs /** * @param 1 : UL Menu ID * @param 2 : Target Tab Content ID * @param 3 : Initially Loading Tab’s Id * @param 4 : Don’t know yet, just use as it is (LOL) */ frontend_tabsJsTabs = new varienTabs(‘page_tabs’, ‘tabcontainer’, ‘normaltab’,[]); </script> [/source] Done! You must now have a functioning Tab loading by Ajax and Normal, but yes tab would look good if you add CSS to your Tabs. :P Here is how it works.
  1. On load it first copies the tab_content div inside the Target Tab Content ID div.
  2. On tabbed menu clicked it checks its class name and if it class name does not have “ajax” it simply shows the its_content div.
  3. If the menu clicked has “ajax” then it checks for another class name “notloaded”. So if its ajax and notloaded it then makes an Ajax request and updates the responseText to itsid_content div and then removes the “notloaded” class name for the menu. After that it then displays the itsid_content div, hiding previous ones.
  4. If you re-click the “Ajax” typed menu, it will not find “notloaded” class in its menu, then it just shows its_content div.
A good trick, I thought while doing this, using class name to restrict the Ajax call.

Analysis & Usage of Collections in Magento

As a Magento Programmer I am fascinated by the use & simplicity of collection used in Magento. Simplicity, does not really mean being simple (it is rather complex structured) but easy to use. With the help of one of my colleague, I got down to understand how collection really represents the “collection” of data we are actually trying to get from database. Here is what I found drilling down into the Magento’s Core. I may be “not quite right” with the analysis, you can always comment. Almost all the collections found inside app/code/codepool/Namespace/Module/Model/Mysql4/model/Collection.php are the child of parent Class Mage_Core_Model_Mysql4_Collection_Abstract. Primary thing done in the class constructor is initializing its resource and Model. If you look into one of the Collection class you can see in its constructor. [source language=”php”] /** * @class Mage_Checkout_Model_Mysql4_Agreement_Collection * Initialize resource * */ protected function _construct() { $this->_init(‘checkout/agreement’); } [/source] And this _init function has been implemented in its parent class as [source language=”php”] /** * Standard resource collection initalization * * @param string $model * @return Mage_Core_Model_Mysql4_Collection_Abstract */ protected function _init($model, $resourceModel=null) { $this->setModel($model); if (is_null($resourceModel)) { $resourceModel = $model; } $this->setResourceModel($resourceModel); return $this; } [/source] The resource class can be found in app/code/codepool/Namespace/Module/Model/Mysql4/model.php. And this resource class in turn initializes the database table to be used in the Module along with the table’s primary key. [source language=”php”] class Mage_Checkout_Model_Mysql4_Agreement extends Mage_Core_Model_Mysql4_Abstract { protected function _construct() { $this->_init(‘checkout/agreement’, ‘agreement_id’); } …… } [/source] It is this resource class that actually works out the database connections, read/write adapters and performs transactions. So this is the basic deduction about the link of collection with the database and its tables. But how are those collection formed still remains a mystery, not anymore! In this section of the post I will try to explain how are the collections really formed. If I can, ”collection” can be defined as collection or array of its resource. And in Magento case, most of the resources are database’s query results. Simply you can visualize ”collection” to be array of your model’s resource. If a ”query” in Magento returns a collection of all the products then it would mean that the very collection is an array of all the individual product’s object. But one question still remains how will the database query’s result transform into a Magento ”collection”. To understand that we need to understand the collection class and its parents. The class Structure for Mage_Core_Model_Mysql4_Collection_Abstract is like this. Mage_Core_Model_Mysql4_Collection_Abstract

|__ Varien_Data_Collection_Db (C)

|__ Varien_Data_Collection (C)

|__ IteratorAggregate (I)

|__ Countable (I)

You can see that all collection implements two Interfaces IteratorAggregate & Countable. IteratorAggregate is predefined in Standard PHP Library that extends Abstract Base Class Traversable . On using this Interface you can then Iterate Through Object using ”foreach” construct. Countable returns the size of the Collection Object. Among the two Interfaces, IteratorAggregate is particularly important. As you can see in Class Hierarchy both the interfaces are implemented by Varien_Data_Collection concrete class. IteratorAggregate has abstract public method getIterator() which returns the Iterator interface and the concrete Class has to implement the method on its own. It is this Iterator that provides the real iteration functionality. You can get a detailed description about Iterator Here. So if you look into the Varien_Data_Collection you will find the getIterator() implemented like this. [source language=”php”] /** * @class Varien_Data_Collection * Implementation of IteratorAggregate::getIterator() */ public function getIterator() { $this->load(); return new ArrayIterator($this->_items); } [/source] As you can see that it first loads the ”items” (I will get back to this Items) and instanciates the value to an internal Class ArrayIterator . And the Iterator returned by this function can then be iterated using foreach construct. Looks like it is going to be a looonnnnng post, let be summarize what I’ve tried to point out until now. I’ve tried to show the link between the collection class or rather object with the database table and explain the iteration behavior of the collection object. But one question still remains how will the database query’s result transform into a Magento’s ”collection”. This is where the ”items” explanation need to be done. ”Items” are actually array if individual object (item) of the collection which represents the array of tuple of the database query result. As you see in the snippet above the ArrayIterator takes $this->_items are parameter. But $this->_items are not populated here on Varien_Data_Collection but rather on is child class Varien_Data_Collection_Db. Here’s the snippet from Varien_Data_Collection_Db. [source language=”php”] /** * Load data * @class Varien_Data_Collection_Db * @return Varien_Data_Collection_Db */ public function load($printQuery = false, $logQuery = false) { if ($this->isLoaded()) { return $this; } $this->_renderFilters() ->_renderOrders() ->_renderLimit(); $this->printLogQuery($printQuery, $logQuery); // Getting Data from DB $data = $this->getData(); $this->resetData(); if (is_array($data)) { // Looping on each result row foreach ($data as $row) { // Creating Empty "item" Varien_Object’s object $item = $this->getNewEmptyItem(); if ($this->getIdFieldName()) { $item->setIdFieldName($this->getIdFieldName()); } // Setting Varien_Object’s values to that of the row $item->addData($row); /** * Adding the "item" to the collection @class Varien_Data_Collection * So while referring to $this->_items @class Varien_Data_Collection it will return array of this "item" */ $this->addItem($item); } } $this->_setIsLoaded(); $this->_afterLoad(); return $this; } /** * Get all data array for collection * @class Varien_Data_Collection_Db * @return array */ public function getData() { if ($this->_data === null) { $this->_renderFilters() ->_renderOrders() ->_renderLimit(); // Fetching all the row with the Select query set $this->_data = $this->_fetchAll($this->_select); $this->_afterLoadData(); } return $this->_data; } [/source] You can go through the inline comments I’ve added. This is it, I’ve finally worked out the explanation of structure & creation of Magento’s Collection and its iterative behavior. I’ve tried to show pictorially (below) what I have just described. Confused! Plz comment and of course please do comment if I am wrong, because there are “times” when you try to understand things even though they actually aren’t just like you think. I’d like to quote Paulo :“I see the world in terms of what I would like to see happen, not what actually does”! hierarchy

Magento eCommerce: How to Reset All Test Order Information and Set Unique Prefix for Orders, Invoices, Shipments, and Credit Memos

Nice Post I stumbled upon.. from www.eliasinteractive.com. This is a very helpful hack Lee has posted to reset order information while moving from development stage to production stage. I’d tried this in Enterprise Edition as well and it worked! Just a Re-Post :P Magento eCommerce: How To Reset All Test Order Information and Set Unique Prefix For Orders, Invoices, Shipments, and Credit Memos.

Solution: Error Message Not Showing Up in Frontend in Magento

I recently got to a situation where I needed to add a new frontend template for some module and after some action show the error or success message. Not the first time though :P. Interesting thing was even if I added this code in the PHTML file. [source language=”php”] <?php echo $this->getMessagesBlock()->getGroupedHtml() ?> [/source] It did not work. Yes, after adding this block it had worked before. In my case, the probable case might be that I had called the module’s template from CMS page. In other case it should work. So, I looked for work around and the following did the trick. [source language=”php”] // Getting Messages from Session $messages=Mage::getSingleton("customer/session")->getMessages(); // Creating Block Mage_Core_Block_Messages // Setting Message // echoing the Message’s HTML echo $this->getLayout()->createBlock("core/messages")->setMessages($messages)->getGroupedHtml(); [/source] The Error/Success or Notice messages are set on session. So what I did was take those message/s from the session and create a new block, same as what $this->getMessagesBlock() might have called, and set those message to the created block and echoed its HTML. Clever? or not?

Redirect to Some Other Location From Model or Observer in Magento

Redirection in Magento’s controller is simple. You just need to call a _redirect() or _forward() function and provide appropriate router/controller/action parameter. But if you want to redirect to some other page from Model or from Observer, then this can be tricky. Lets take an example, for explaining what I am referring to, Suppose you are building a module that will only allow user of certain group to view a product in frontend. Then, you will have options like:
      Rewrite you catalog/product/view controller and add that logic.
      Rewrite Block of that page and show error message accordingly.
      Any other..?
Yeha, I do have another option as well. The Event-Observer Method. You can observe an event controller_action_predispatch_catalog_product_view and set up an observer where you can write your own logic there and redirect accordingly. You can observe that event by setting up your config something like this. [source language=”xml”] <controller_action_predispatch_catalog_product_view> <observers> <mymodel> <type>singleton</type> <class>mymodel/controller_observer</class> <method>controller_action_predispatch_catalog_product_view</method> </mymodel> </observers> </controller_action_predispatch_catalog_product_view> [/source] And on the observer’s controller_action_predispatch_catalog_product_view method, you can check your logic for visibiliy of that product to the logged in user group and redirect if not visible. Here’s the main point of this post (Did I take a lot of your time ?), in that same method you can directly redirect using the following snippet of code. [source language=”php”] Mage::app()->getResponse()->setRedirect(Mage::getUrl("myrouter/mycontroller/noview")); [/source] Adding an error message to the session would be a good idea, for user to understand what is happening. Else you can directly call a template in the redirected controller’s action with appropriate message. I think this sums up the post for now..and as always hoping it helps somebody and waiting for the response.