Magento 中没有 GET 参数的开关商店
我想从一家商店到另一家商店进行不可见的重定向(我设置了多商店) 进入我的模块,现在我正在使用这个片段,但它显示 GET 参数:
echo '<p><a href="' . Mage::getUrl() . '?___store=' . $store . '">pick up this restaurant</a></p>'
我怎样才能实现这个?
谢谢
I would like to make an invisible redirection from a store to a different one (I set up multistore)
into my module, for now I'm using this snippet but it shows GET parameter:
echo '<p><a href="' . Mage::getUrl() . '?___store=' . $store . '">pick up this restaurant</a></p>'
How can I achieve this ?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您必须为商店设置
COOKIE
例如:
You have to set
COOKIE
for the storeFor example :
也许你可以使用表单(方法post),并根据处理后的数据,设置商店:
Mage::app()->setCurrentStore(store_id)
Maybe you could use forms (method post), and acording to the processed data, set the store:
Mage::app()->setCurrentStore(store_id)
使用 POST 表单意味着当使用后退按钮时,客户可能会在浏览器中遇到恼人的“此页面需要刷新”消息。另一种方法是在某些早期事件期间(例如在控制器预调度期间)从
www.example.com/?___store=1
重定向到www.example.com
。仅当存在___store
参数时才重定向。更好的方法是为每个商店设置不同的域。这完全避免了
___store
参数,并向客户提供明确的反馈,表明他们位于正确的网站上。Using a POST form means that when using the back button customers might encounter an annoying "This page needs to be refreshed" message in their browser. Another way would be to redirect from
www.example.com/?___store=1
towww.example.com
during some early event, say, during controller pre-dispatch. Only redirect if there is a___store
parameter.A better way would be to have different domains for each store. That avoids the
___store
parameter altogether and provides definite feedback to the customer that they are on the correct site.您可以将商店代码放入 cookie 中,并让您的 index.php 检查 cookie 是否存在,如果存在,则通过其代码加载商店,如果不存在则显示默认商店。
You can put the store code in a cookie and have your index.php check to see if the cookie exists or not, if it does then it load up the store by its code, if not show default store.
将商店代码添加到网址,您可以从管理页面启用此功能
Add store code to urls you can enable this from admin page