best way to redirect to a selected store
I set a magento website with several stores, I'm making a list of all thoses stores in a page where the user can pick up the nearest one using a form like this
<form action="<?php echo ;?>" method="post">
<input type="submit" value="select store" />
</form>
<form action="<?php echo ;?>" method="post">
<input type="submit" value="select store" />
</form>
In the action attribute I would like to set the url of each store according to his Id... Is it possible? Is there a better way to proceed (maybe avoiding GET parameter)?
Edit: Finally I achieve what I was looking for with this snippet
echo '<p><a href="' . Mage::getUrl() . '?___store=' . $store . '">pick up this restaurant</a></p>';
It's quite close of what clockworkgeek suggest
echo '<p><a href="' .Mage::getUrl('', array('___store'=>$store)) . '">pick up this restaurant</a></p>';
but results are differents:
my test:
http://test.mysite.com/?___store=3
clockworkgeek code:
http://test.mysite.com/___store/3/
The first link is working fine, the second lead to a 404 one...
Also I try this code which is producing nothing, Any idea why ?
Mage::app()->setCurrentStore(5);
$this->_redirect('');
The redirection is working fine, but I'm still on the same store, Is it the good way of using setCurrentStore function?
then I finally have a go with this one, but I can find suitable exam开发者_如何学JAVAple on the net about it... how can I using it, and related question how can i Hve the list of all the magento controllers ?
$this->_forward('defaultNoRoute');
thx
Perhaps you are thinking of getUrl()
. For example:
echo Mage::getUrl('', array('_store'=>$storeId));
http://www.magentocommerce.com/wiki/5_-_modules_and_development/reference/geturl_function_parameters
You should bind the submit button using JQuery events and then use window.location
to redirect to the selected store.
It should be quite similar to the code given in the first answer here: Redirect automatically when selecting an item from a select drop-down list
精彩评论