2

I want to include the account page in the main menu. So I created a category page. My first try was that I put to the URL Key input the value customer/account, but Magento saved the value as customer-account. After that I tried to do it from URL Rewrite Management, it worked until the first reindexing. I do not want to do it from .htaccess.

Is there another way to do a redirect ? thx

3

Edit:

In order to full fill your requirement, need to use Event/Observer

Create a custom module and using catalog_controller_category_init_after event for redirect to account page

update:


On this event fire an observer which redirect to customer/account page on basic of your condition using magento FrontController redirction action Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/index'));

Mage::app()->getResponse()->sendResponse();

Observer code:

<?php 
class [ModuleNameSpace]_[ModuleName]_Model_Observer{

public function redirectNotLogged(Varien_Event_Observer $observer)
{
    $action = strtolower(Mage::app()->getRequest()->getActionName());
    $controller = strtolower(Mage::app()->getRequest()->getControllerName());
    $controller_action= $observer->getEvent()->getControllerAction();

       $category = $observer->getEvent()->getCategory();


  /* here check category id and redirect to specific field */

  if($category->getId()):
   Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/index'));
  exit();
  endif;
      return;
  } 

}

config.xml:

....
<config>
  <global>
    <events>
      <catalog_controller_category_init_after>
        <observers>
            <redirect_to_account>
              <class>[ModuleNameSpace]_[ModuleName]_Model_Observer</class>
              <method>redirectNotLogged</method>
            </redirect_to_account>
        </observers>
      </catalog_controller_category_init_after>
    </events>
  </global>       
</config>
  • So I should create a new module , which will have an obsever which extend that class, where I should do the redirect? Shouldn't be easier if i create a static block, where i should create my main menu and included in the header? – Attila Naghi Nov 11 '15 at 8:04
  • You need to create a custom module – Amit Bera Nov 11 '15 at 8:10
0

Usually we approach your problem from a different point of view.
We do not modify the category tree, but only the phtml that render the nav menu.
The menù template used depends from many factors (layered nav, custom themes) but usually it is based on block:
Mage_Catalog_Block_Navigation

in the function:
_renderCategoryMenuItemHtml

regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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