Once we click on "ADD TO CART" in "My account" page and if we open any other pages like home page , catalog page, product page, i can see message there, but not displaying in My account page.

Edit end

In "My designs" section, Under My account we are displaying some products and gave an option for "Add to cart" and its working fine.

enter image description here

now i need to display message on top of the page after customer click on "Add to cart" similar to product view page :

enter image description here

For "Add to cart" button, i am trying same code that we are using in product view page, but its not displaying any message.


<?php $collections = $this->getCollection(); ?>

<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = Mage::helper('core')->quoteEscape($this->__('Add to Cart')); ?>

<?php foreach ($collections as $key => $product) {

    echo $product->getName().' <br>';
<form action="<?php echo  Mage::helper('checkout/cart')->getAddUrl($product);?>" method="post">  
<div class="add-to-cart-buttons">

<button type="submit" title="<?php echo $buttonTitle ?>" class="button btn-cart" >
    <?php echo $buttonTitle ?>

<?php echo $this->getChildHtml('', true, true) ?>

<hr style='display:inline-block; width:100%;'>



app/code/local/Amasty/Example/controllers/mydesigncontrollers.php - http://pastebin.com/rpjjMthf


2 Answers 2


To add messages on your page, you need to add Layout Message block on your controller. Here in your case, app/code/local/Amasty/Example/controllers/MyDesignController.php

public function indexAction() {

And get Groped Html on top in your phtml, app/design/frontend/rwd/Stylebaby/template/example/example.phtml

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

try below code

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>


<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>

add below code into your controller after load Layout

  • Thanks, i tried your code as here, but it didt worked for me, what wrong i am doing here : pastebin.com/FjiUx2tr Commented Mar 24, 2017 at 11:10
  • I edited question, when you get free time, please look once..... Commented Mar 24, 2017 at 11:47
  • after adding product to cart on which page it is redirecting? @BabyinMagento Commented Mar 24, 2017 at 13:02
  • it staying in same page, but not displaying any message in same page, but when i opened any other pages, its displaying message there..... Commented Mar 24, 2017 at 13:05
  • you are using Ajax ? @BabyinMagento Commented Mar 24, 2017 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.