viraxpress / restriction
ViraXpress Restriction Extension for Magento2
Package info
github.com/viraxpress/Restriction
Type:magento2-module
pkg:composer/viraxpress/restriction
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0
README
A Magento 2 extension to create flexible access restrictions for products, category pages, CMS pages, and CMS blocks, with customer group and store-scoped rules.
Description
ViraXpress_Restriction lets admins define restriction rules that control frontend user access and behavior based on:
- Customer group
- Store view(s)
- Date range (
start_at,end_at) - Restriction target types: products, categories, CMS pages, CMS blocks
- Response action: show an error message or redirect URL
Active restrictions apply in real-time via frontend event observers.
Features
- Admin UI under Stores > Manage Restriction > Restriction Rule
- Enable/disable module globally via system configuration (
VX Restriction > General > Enable Manage Restriction) - Create/ edit/ delete rule records in grid UI
- Restrict by:
- specific products
- product categories (and filter product collections globally)
- CMS pages
- CMS blocks
- Add-to-cart blocking for restricted product rules
Compatibility
- Magento 2.4.x
Installation
-
Install the extension via Composer:
composer require viraxpress/restriction
-
Run the following commands from your Magento root directory:
php bin/magento module:enable ViraXpress_Restriction php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento cache:flush
Usage
Configuration
Navigate to Stores > Configuration > VX Restriction > General and set Enable Manage Restriction to Yes.
Managing Restriction Rules
Go to Stores > Manage Restriction > Restriction Rule and click Add New Restriction Rule.
- Set a title, date range, store view, and customer group for the rule.
- Choose a response type —
Error Message(with custom text) orRedirect(with a target URL). - Enable Restrict Products and select specific products.
- Enable Restrict Categories to block access to category pages and filter their product collections.
- Enable Restrict CMS Pages or Restrict CMS Blocks to hide specific pages or blocks.
How It Works
- On each frontend request, observers check if the current customer's group matches an active rule within its date range and store view scope.
- Exact product matches take priority over
allwildcard matches. - On a match, the user is either shown an error message or redirected to the configured URL.
- Disabling the module globally bypasses all observer checks without requiring rule deletion.