0
votes

I really really can't seem to find a way to set a specific store view for a customer group. I have 1 view showing prices including VAT and 1 view showing prices without VAT.

Now I want my group of resellers to automaticly view the store in the "resellers store view" so they see the prices w/o VAT.

There seems to be no way of doing this!

Thanks in advance!

Edit

Thanks!

I inserted @Jakub Korupczyński code in the index.php but just after the Mage::run() And now its working!

I indeed think it will be better to make an extention for this, so I'm in the process of learing it. But in the mean time this will do!

Edit2

Seems it not working after all. The code after Mage::Run is not reached...

1

1 Answers

4
votes

You need to create a new extension with observer.

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

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>

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
        }
      }
  }
}

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.