I want to restrict product by customer group.

For mapping, we added an attribute to product called group_ids where admin can select multiple customer groups

I want to restrict customer to access this product if their customer group is not assigned to the product.

I want to restrict product access from upsell,crosssell,related,wishlist,product page,category page, home page every where.

So i was looking for function where magento filter product by website. i want to override it add my custom logic to filter but not able to find out that function

So if anyone knows about it then please provide me information of that function or if there any other way to do it


I found magento event catalog_product_collection_apply_limitations_after

which is called after all basic limitations applied.


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="catalog_product_collection_apply_limitations_after">
        <observer name="catalogaccess_filter" instance="Mymodule\Catalogaccess\Observer\BrandAccess" />


public function execute(\Magento\Framework\Event\Observer $observer)
    $collection = $observer->getEvent()->getCollection();
    return $this;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.