Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you do programming then simple logic would be checking if user is logged in or not else redirect them to the login page using event: controller_action_predispatch.<br /> 1> In your config.xml add the following xml code:</p> <pre><code>... &lt;frontend&gt; &lt;events&gt; &lt;controller_action_predispatch&gt; &lt;observers&gt; &lt;yourmodule_controller_action_predispatch&gt; &lt;class&gt;yourmodule/observer&lt;/class&gt; &lt;method&gt;checkForLogin&lt;/method&gt; &lt;/yourmodule_controller_action_predispatch&gt; &lt;/observers&gt; &lt;/controller_action_predispatch&gt; &lt;/events&gt; &lt;/frontend&gt; ... </code></pre> <p>2> Create a Observer.php in your Module's Model/ directory.<br /> Here is the basic code that you need to use in your Observer class:</p> <pre><code>&lt;?php class YourCompany_Yourmodule_Model_Observer extends Varien_Object{ public function checkForLogin(Varien_Event_Observer $observer){ if(!Mage::getSingleton('customer/session')-&gt;isLoggedIn() &amp;&amp; $observer-&gt;getControllerAction()-&gt;getFullActionName() != 'customer_account_login') { Mage::app()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl('customer/account/login'))-&gt;sendResponse(); exit; } } } </code></pre> <p>If you are interested with more robust solution with much more features ready to use for your B2B store then here is an awesome Magento Extension called 'Store Restriction Pro': <a href="http://www.magepsycho.com/store-restriction-pro.html" rel="nofollow">http://www.magepsycho.com/store-restriction-pro.html</a></p> <p>Good Luck</p> <hr> <h2><strong>Update</strong> (13-11-27), JSOV</h2> <p>In order to allow the forgot password, login access and default funcionality, you can add an array of the default pages you want to give permissions, and then validate and redirect. ex:</p> <pre><code>... $allow = array('customer_account_login','customer_account_forgotpassword','customer_account_resetpassword','customer_account_loginpost','customer_account_forgotpasswordpost','customer_account_resetpasswordpost'); if(!Mage::getSingleton('customer/session')-&gt;isLoggedIn() &amp;&amp; !in_array(strtolower($observer-&gt;getControllerAction()-&gt;getFullActionName()),$allow) ) { ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload