0

i'm a beginner so excuse me in advance! I've made a custom module for create a nested categories dropdown.

My module solution is differnet from this https://stackoverflow.com/questions/23168353/nested-categories-dropdown-in-magento but I've start with this one. It's done with a same logic.

Now I've got a big problem. When i post the form i would like to redirect to a catalog page filter by the category id that i passed with post method of my form.

So if I undersand I have to make a function "saveAction" on my IndexController.

but what I have to write in it? How can make a redirect to this specific page?

i've try it but it doesn't Work

    public function saveAction()
 {
    $catID = ''.$this->getRequest()->getPost('CatId');
    if(isset($catID)&&($catID!='') )
   {
        $_category = Mage::getModel('catalog/category')->load($catID);
        $redirect = $_category->getUrl($_category); 
        $this->getResponse()->setRedirect($redirect);
   }
}
0

At the end i do so:

public function filterAction()



{
    //recupero i parametri passati nella chaimata POST
    $ParentID = ''.$this->getRequest()->getPost('ParentId');
    $catID=''.$this->getRequest()->getPost('CatId');
    //verifico i parametri
    if(isset($catID)&&($catID!='') && isset($ParentID)&&($ParentID!='') )
   {
        $redirect = Mage::getModel('catalog/category')->load( $ParentID)->getUrl();
        $redirect = $redirect . '?cat=' . $catID;
        $this->getResponse()->setRedirect($redirect);

        }
    }

In practice from my Post i get the ID of my parent Category (Level 1) and of the last child category and I create my custom url in this way

$redirect = Mage::getModel('catalog/category')->load( $ParentID)->getUrl();
    $redirect = $redirect . '?cat=' . $catID;

It's not seem to be the best solution but for now its work fine and i didn't find a better solution yet.

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.