특정 고객 세그먼트에 카테고리를 제한하십시오
-
29-09-2020 - |
문제
My Store (Mage-EE v12)에서는 특정 고객 세그먼트를 제한하려는 카테고리가 있습니다.누구든지 내가 이것을 할 수있는 방법을 알고 있습니까?
예를 들어, 세그먼트를 설정하면이 세그먼트의 고객이 전체 카탈로그에 액세스 할 수 있도록 원하는 경우 그러나 고객 이이 세그먼트에 빠지지 않으면 제한 범주의 가시성이 없습니다.
이견있는 사람 ?
건배
해결책
귀하의 요구 사항에 대한
- 먼저 admin에서 새 고객 그룹을 만들어야합니다.
- 이 그룹에 특정 고객 세그먼트를 할당합니다.
- 이벤트 / 옵저버
catalog_controller_category_init_before
를 사용합니다 고객이 특정한 것을 제외하고는 고객 이이 카테고리를 방지합니다 카테고리
config.xml :
<config>
<global>
<config>
<events>
<catalog_controller_category_init_after>
<observers>
<redirect_to_account>
<class>[ModuleNameSpace]_[ModuleName]_Model_Observer/class>
<method>redirectNotLogged</method>
</redirect_to_account>
</observers>
</catalog_controller_category_init_after>
</events>
</config>
</global>
</config>
.
observer.php
<?php
class [ModuleNameSpace]_[ModuleName]_Model_Observer{
public function redirectNotLogged(Varien_Event_Observer $observer)
{
$action = strtolower(Mage::app()->getRequest()->getActionName());
$controller = strtolower(Mage::app()->getRequest()->getControllerName());
$controller_action= $observer->getEvent()->getControllerAction();
$category = $observer->getEvent()->getCategory();
/* if category is not Match with your category then continue default behave */
if($category->getId()!='YOUR_CATEGORY_ID'):
return true;
endif;
/* Customer group id match and then previllage to access that category page.*/
if (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId()=='CUSTOMER_GROUP_ID') {
return true;
}
Mage::app()->getResponse()->setRedirect($_SERVER['HTTP_REFERER']);
Mage::app()->getResponse()->sendResponse();
exit;
}
}
.
또는 와 같은 확장자 사용
제휴하지 않습니다 magento.stackexchange