更新时间:2023-11-30 12:51:28
您需要使用观察者创建新的扩展名.
You need to create a new extension with observer.
对于实例,我创建了扩展Jakkor_Setstore.因此文件夹看起来像这样:
For Instance I created extension Jakkor_Setstore. So the folders looked like this:
app/code/local/Jakkor
app/code/local/Jakkor/Setstore
app/code/local/Jakkor/Setstore/etc
app/code/local/Jakkor/Setstore/Model
在其他地方,有一个文件"config.xml":
In etc there was a file "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>
在Model中,有一个文件"Observer.php":
In Model there is a file "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"中:
And of course in app/etc/modules "Jakkor_Setstore.xml":
<?xml version="1.0"?>
<config>
<modules>
<Jakkor_Setstore>
<active>true</active>
<codePool>local</codePool>
</Jakkor_Setstore>
</modules>
</config>
这已经过测试,并且可以正常工作.对不起,一团糟.我没有测试第一种方法.我认为应该可以.
This was tested and it is working. Sorry for the mess before. I didn't test the first approach. I thought that it should work.