特定の顧客セグメントにカテゴリを制限します
-
29-09-2020 - |
質問
私の店で(Mage-EE V12)私は特定の顧客セグメントに制限したいカテゴリを持っています。誰かが私がこれを行うことができる方法を知っていますか?
たとえば、セグメントをセットアップした場合、このセグメントの顧客がフルカタログにアクセスできるが、顧客がこのセグメントに分類されない場合、それらは制限されたカテゴリの可視性を持たないのですか?
何かご意見は ?
歓声
解決
あなたの要求のために
- 最初に管理者から新しい顧客グループを作成する必要があります。
- このグループに特定の顧客セグメントを割り当てます。
- その後、イベント/オブザーバ
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;
}
}
.
またはexpection
のような使用所属していません magento.stackexchange