Question


In my store (mage-EE v12) I have a category that i want to restrict to a specific customer segment. Does anyone know of a way i can do this?
EG, if i set up a segment, I want customers in this segment to have access to the full catalog, but if the customers does not fall into this segment they have no visibility of the restricted category?
Any thoughts ?
Cheers

Was it helpful?

Solution

For your requirement.

  • First you need to create a new customer group from admin .
  • Assign specific customer segment to this Group.
  • Then using event/observer catalog_controller_category_init_before prevent customer to go this category except that specific category

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

Or use extension like

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top