您需要使用观察者创建一个新扩展。
例如,我创建了扩展 Jakkor_Setstore。所以文件夹看起来像这样:
app/code/local/Jakkor
app/code/local/Jakkor/Setstore
app/code/local/Jakkor/Setstore/etc
app/code/local/Jakkor/Setstore/Model
在 etc 中有一个文件“config.xml”:
<?xml version="1.0"?>
<config>
<global>
<models>
<setstoreobserver>
<class>Setstore_Model</class>
</setstoreobserver>
</models>
</global>
<frontend>
<events>
<controller_action_predispatch>
<observers>
<jakkor_setstore_model_observer>
<type>singleton</type>
<class>Jakkor_Setstore_Model_Observer</class>
<method>setstore</method>
</jakkor_setstore_model_observer>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
在模型中有一个文件“Observer.php”:
class Jakkor_Setstore_Model_Observer extends Varien_Event_Observer
{
public function setstore($observer)
{
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //get the group id
if($groupId == 2) //I don't know what id has your reseller group, so 2 is an example, you need to set here the specific group
{
Mage::app()->setCurrentStore(2); //Set id of the store view without vat
}
else {
Mage::app()->setCurrentStore(1); //set the store view with vat
}
}
}
}
当然在 app/etc/modules "Jakkor_Setstore.xml" 中:
<?xml version="1.0"?>
<config>
<modules>
<Jakkor_Setstore>
<active>true</active>
<codePool>local</codePool>
</Jakkor_Setstore>
</modules>
</config>
这是经过测试的,它正在工作。对不起之前的混乱。我没有测试第一种方法。我认为它应该工作。