에 방문 제품 페이지에 대한 사용자를 보호하는 방법, 요구 사항입니다.내가 젠토 사이트 있어요 젠토
등록 후 그는 제품을 볼 수있게됩니다. 이미 시도했지만 아직 해결 방법을 얻지 못했습니다. 누구든지이 문제를 해결할 수 있습니까?
에 방문 제품 페이지에 대한 사용자를 보호하는 방법, 요구 사항입니다.내가 젠토 사이트 있어요 젠토
등록 후 그는 제품을 볼 수있게됩니다. 이미 시도했지만 아직 해결 방법을 얻지 못했습니다. 누구든지이 문제를 해결할 수 있습니까?
이
Step 1: Go to Admin => System => Configuration => Customer Configuration => Login Options => "Redirect Customer to Account Dashboard after Logging in" set it "No".
Step 2: If you're using a module page then you've the controller Action method like:
public function indexAction()
{
// use here to restrict the page //
if(!Mage::helper('customer')->isLoggedIn()){
Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
$this->_redirect('customer/account/login');
}
// End your addition //
$this->loadLayout();
$this->renderLayout();
}
you can use one of this code to redirect:
Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
$this->_redirect('customer/account/login');
OR
$this->_redirect('customer/account/login/referer/'.Mage::helper('core')->urlEncode('Restricted Page Url'));
Step 3: (optional) If you're using a cms page then follow this step:
In your admin CMS section include a phtml page and write the below code at the top of the page:
if(!Mage::helper('customer')->isLoggedIn()){
Mage::getSingleton('customer/session')->setBeforeAuthUrl('Restricted Page Url');
$this->_redirect('customer/account/login');
}
>> Now if you want to use the login url inside a page with referer url follow this:
<?php $referer = Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl()); ?>
<a href="<?php echo Mage::getUrl('customer/account/login', array('referer' => $referer)) ?>">Login</a>
나는이 문제를 해결할 것이라고 생각 사용하십시오
magento connect에서 무료로 사용 가능한 확장 프로그램을 간단하게 사용할 수 있습니다. 내 가게에이 연장통을 사용했습니다. http://www.magentocommerce.com/magento-connect/login-check.html
무료이며 잘하고 있습니다.
다음 접근 방식을 described here으로 시도 할 수 있습니다. 단일 링크 답변 게시는 권장되지 않으므로 다음과 같이하십시오.
프런트 엔드에 대한 이벤트 controller_action_predispatch
의 옵저버를 만들어야합니다. 사용자 정의 모듈에서이를 수행 할 수 있습니다. 이 모듈을 Easylife_Restrict
라고 부르 자.
다음과 같은 파일이 필요합니다 :
app/etc/modules/Easylife_Restrict.xml
을 - 선언 파일을.
<?php
class Easylife_Restrict_Model_Observer{
public function redirectNotLogged(Varien_Event_Observer $observer)
{
//get the current request action
$action = strtolower(Mage::app()->getRequest()->getActionName());
//get the current request controller
$controller = strtolower(Mage::app()->getRequest()->getControllerName());
//a list of allowed actions for the not logged in user
$openActions = array(
'create',
'createpost',
'login',
'loginpost',
'logoutsuccess',
'forgotpassword',
'forgotpasswordpost',
'resetpassword',
'resetpasswordpost',
'confirm',
'confirmation'
);
//if the controller is the customer account controller and the action is allowed for everyone just do nothing.
if ($controller == 'account' && in_array($action, $openActions)) {
return $this; //if in allowed actions do nothing.
}
//if the user is not logged in redirect to the login page
if(! Mage::helper('customer')->isLoggedIn()){
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'));
}
}
}
지우기 캐시를하고 그것을 제공 :
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Restrict>
<codePool>local</codePool>
<active>true</active>
<depends>
<Mage_Customer />
</depends>
</Easylife_Restrict>
</modules>
</config>
app/code/local/Easylife/Restrict/etc/config.xml
- 구성 파일
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Restrict>
<version>1.0.0</version>
</Easylife_Restrict>
</modules>
<global>
<models>
<easylife_restrict>
<class>Easylife_Restrict_Model</class>
</easylife_restrict>
</models>
</global>
<frontend>
<events>
<controller_action_predispatch>
<observers>
<easylife_restrict>
<class>easylife_restrict/observer</class>
<method>redirectNotLogged</method>
</easylife_restrict>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
는
app/code/local/Easylife/Restrict/Model/Observer.php
- - 모듈 관찰자는 마법의 발생이되는 경우 시험.