如何将不同的用户组重定向到Magento中的不同页面?
我想要做的是为每个客户群分配一个类别,以便在登录时将用户重定向到该用户。
非常感谢。
答案 0 :(得分:2)
我没试过这个。我认为您需要在customer_login
事件中执行以下操作:
$session = Mage::getSingleton('customer/session');
$category = // A category object based on $session->getCustomerGroupId()
$session->setBeforeAuthUrl($category->getUrl());
答案 1 :(得分:2)
转到/app/code/local/MagentoPycho/Customer/controllers/AccountController.php并替换它:
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
用这个:
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($groupId == 5) {
$session->setBeforeAuthUrl('http://google.com');
} else {
// Set default URL to redirect customer to
$session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
}
请务必使用您的群组ID代替“5”以及您的重定向网址而不是google.com。
我刚尝试过。
答案 2 :(得分:1)
这种做法如何:
考虑从现有模块开始,例如:
http://www.magentocommerce.com/magento-connect/MagePsycho/extension/3763/custom_login_redirect
然后添加自己的逻辑。对于客户的组名,您可以尝试:
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
$group = Mage::getModel ('customer/group')->load($groupId)->getCode();
如果您的类别按照您的组命名,则可以重定向到http:// + base_url + $ group,从而无需明确确定要加载的类别页面。
答案 3 :(得分:0)
为了按客户群重定向客户,有一个商业扩展: http://www.magepsycho.com/custom-login-redirect-pro.html 真的很值得尝试。仅供参考,许多商家将此模块用于其magento网站。
快乐的电子商务!! 此致