Child pages
  • Customer Group Catalog Permissions - Magento 2
Skip to end of metadata
Go to start of metadata

Icon

Firefox user notice:

Please use a different web browser to view this document.

Sorry for the inconvenience.

Magento 2 Customer Group Catalog Permissions is equipped with rich functionality in the backend and easy to implement functionality in the frontend. The backend includes both individual and mass settings. The individual ones allow an admin to set the permissions for each category, product and CMS page separately. Mass settings provide the opportunity to configure and delete permissions for the unlimited number of store catalog elements at once.

Both individual and mass settings are aimed at visibility management of the element itself, its price and add to cart button. More to that, it’s possible to assign text messages equipped with CSS-styles and configure the redirection instead of hidden elements.

 Compatibility: Magento Open Source 2.2.X, Magento Commerce 2.2.X

Product Page

Thank you for choosing Aheadworks!


Installing Customer Group Catalog Permissions 

To install the extension follow the instructions below:

1. Backup your web directory and store database

2. Download the Customer Group Catalog Permissions installation package

 3. Upload contents of the Customer Group Catalog Permissions installation package to your store root directory

 4. In SSH console of your server navigate to your store root folder:

cd path_to_the_store_root_folder

run:

php -f bin/magento module:enable _CustGroupCatPermissions

then:

php -f bin/magento setup:upgrade

after:

php -f bin/magento setup:static-content:deploy

5. Flush store cache; log out from the backend and log in again

Icon

Make sure the installation is done from under the FTP administrator account. Otherwise, make sure to set 775 permissions to the store root directory after the extension is deployed.

Backend Configuration

 
Icon
Note that firstly, you need to disable native permissions to launch the Customer Group Catalog Permissions by Aheadworks.

1. General Configuration

 


The Configuration page of the extension (Stores > Configuration > Aheadworks Extensions > Сustomer Group Catalog Permissions) includes three sections: General, Catalog Elements Permissions, and CMS Page Permissions.

The General section of the General configuration page allows you to enable the extension via choosing the option ‘Yes’.

Catalog Elements Permissions - section of the Configuration page contains the following configuration options:

Browsing Catalog Elements - the field to be used for the needed mode for the element visibility to be chosen: Show for everyone, Hide from specified customer groups or Hide from everyone;



Note that if you choose mode ‘Hide from specified customer groups’, the following fields appear:

Customer Groups - the field to be used for you to choose the definite customer groups;
Redirect Visitor to This Page - the field to be used for you to insert the URL page for redirection those customers who reach the hidden browsing catalog element;
Display Product Price - the field to be used for the needed mode for the price visibility to be chosen: Show for everyone, Hide from specified customer groups or Hide from everyone.
Allow Adding to Cart - the field to be used for the needed mode for the add to cart button visibility to be chosen: Show for everyone, Hide from specified customer groups or Hide from everyone.

 

 

 


Note that if you choose mode ‘Hide from specified customer groups’ for these two fields (Display Product Price and/or Allow Adding to Cart), the following fields appear:

Customer Groups - the field to be used for you to choose the definite customer groups;

Text Message When Price Is Hidden - the field to be used for you to insert a customized text message using a ready-made HTML-code.

Text Message When Button Add to Cart Is Hidden - the field to be used for you to insert a customized text message using a ready-made HTML-code.

Icon

To display the Hidden Add To Cart Message in the places where the Add To Cart button is displayed, you need to add the following code to the corresponding template:

<?php if ($_product->getHideAddToCart()):?>
<?= /* @escapeNotVerified */ $_product->getHiddenAddToCartMessage(); ?>
<?php endif; ?>

where $ _product is the product object in the template.
Examples
For the Product page:

vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml

For the Category Page:

vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

This code is added wherever it is necessary to display the message and the product object ($ _product) is defined.

Icon

To hide the unwanted text 'Out of stock' when the product permissions are applied, you should:
1) open the template with the output of this text
2) find this text and wrap its output with a conditional construction.

<?php if (!$_product->getHidePrice() && !$_product->getHideAddToCart()):?>

... the output of the text "Out of stock"

<?php endif; ?>

As an example, changes in the vendor / magento / module-catalog / view / frontend / templates / product / list.phtml template:

before:

<?php if ($_product->isAvailable()):?>

    <div class="stock available"> <span> <?= /* @escapeNotVerified */ __('In stock')?> </span> </div>

<?php else:?>

    <div class="stock unavailable"> <span> <?= /* @escapeNotVerified */ __('Out of stock')?> </span> </div>

<?php endif; ?>

after:

<?php if ($_product->isAvailable()):?>

    <div class="stock available"> <span> <?= /* @escapeNotVerified */ __('In stock')?> </span> </div>

<?php else:?>

    <?php if (!$_product->getHidePrice() && !$_product->getHideAddToCart()):?>

        <div class="stock unavailable"> <span> <?= /* @escapeNotVerified */ __('Out of stock')?> </span> </div>

    <? php endif; ?>

<? php endif; ?>


Static Pages
-  the field to be used for the needed mode for the CMS page visibility to be chosen: Show for everyone, Hide from specified customer groups or Hide from everyone.

Note that if you choose mode ‘Hide from specified customer groups’, the following fields appear:

Customer Groups - the field to be used for you to choose the definite customer groups;

Redirect Visitor to This Page - the field to be used for you to insert the URL page for redirection those customers who reach the hidden CMS page.Finally, note that these settings are applied to the whole store catalog without dividing it into separate categories, products or CMS pages. More to that, the settings configured are applied as default unless other individual ones are specified.

That's it. The configuration is done.


2. Category Permissions (individual settings)



If you want to set the permissions for the individual category, you need to reach the New Permission fieldset. The fieldset is available through the following path: Сatalog > Categories > Needed Category chosen from the Category tree > Category Permissions by Aheadworks > New Permission and includes the following columns:

Store View - the website which will be the application scope for the permissions specified;
Customer Group - the particular customer group for which you want to apply the permissions specified;
Category - contains the ‘Show’ or ‘Hide’ modes for you to choose;

 


 

 Product Price - contains the ‘Show’ or ‘Hide’ modes for you to choose;

Icon

 Please note: if you decide to hide the product price, the Add to Cart button is hidden automatically. Instead, you can create a customized text message in the field ‘Text Message When Price is Hidden’ using a ready-made HTML-code.


 

 

Add to Cart Button - contains the ‘Show’ or ‘Hide’ modes for you to choose.

 

Icon

Please note: if you decide to hide the Add to Cart button you can create a customized text message in the field ‘Text Message When Button Add to Cart Is Hidden’ using a ready-made HTML-code.



3. Product Permissions (individual settings)

 

 

If you want to set the permissions for the individual product, you need to reach the New Permission grid. The fieldset  is available through the following path: Products  > Categories > Needed Product chosen from the Product grid  > Edit > Product Permissions by Aheadworks > New Permission and includes the following columns:

Store View - the website which will be the application scope for the permissions specified;
Customer Group - the particular customer group for which you want to apply the permissions specified;
Product - contains the ‘Show’ or ‘Hide’ modes for you to choose;

 

 

 Product Price - contains the ‘Show’ or ‘Hide’ modes for you to choose;

Icon
 Please note: if you decide to hide the product price, the Add to cart button is hidden automatically. Instead you can create a customized text message in the field ‘Text Message When Price is Hidden’ using a ready-made HTML-code.

Add to Cart Button - contains the ‘Show’ or ‘Hide’ modes for you to choose.

 

Icon
Please note: if you decide to hide the Add to Cart button you can create a customized text message in the field ‘Text Message When Button Add to Cart Is Hidden’ using a ready-made HTML-code.

 


4. Static Page Permissions (individual settings)



If you want to set the permissions for the individual CMS page, you need to reach the Static Page Permissions by Aheadworks fieldset. The grid is available through the following path: Content > Pages  > Needed Page chosen from the Page grid > Select  > Edit > Static Page Permissions by Aheadworks > and includes the following columns:

Static Page - contains the ‘Show’ or ‘Hide’ modes for you to choose;
Store View - the website which will be the application scope for the permissions specified;
Customer Group - the particular customer group for which you want to apply the permissions specified. 


5. Update Permissions in Bulk



If you want to update permissions in bulk, you need to reach the Update Permissions in Bulk wizard. The wisard is available through the following path: Catalog > Update Permissions in Bulk and includes the following steps:

Select Catalog Element Type - the step to be made for you to choose between Categories, Products, and Pages;
 Select Items - the step to be made for you to choose the items for which you want to set the permissions;
Set Permissions -  the step to be made for you to set the permissions for the items chosen.

Icon
Please note: the final step requires you to deal with the fieldset which is the similar to this one you see while configuring  individual permission settings for category, product of CMS page. Finally, to update the permissions in bulk you need to click on the button 'Apply' or the button 'Back' to change the previous steps.
Also, pay your attention that this functionality is available not only from the main menu, but also on the page of the individual permission settings for categories - the Category Permissions by Aheadworks page, products - the Product Permissions by Aheadworks page, and CMS page -  the CMS Page Permissions by Aheadworks page.

 


6. Delete Permissions in Bulk

If you need to delete permissions in bulk you need to reach the Delete Permissions in Bulk wizard. The wizard is available through the following path: Catalog > Delete Permissions in Bulk and includes the following steps:

Select Catalog Element Type - the step to be made for you to choose between Categories, Products, and Pages;
Select Items - the step to be made for you to choose the items for which you want to set the permissions.

To delete the permissions you need to click on the button 'Delete' or the button 'Back' to change the previous steps.

Icon

Note that this functionality is available not only from the main menu, but also on the page of the individual permission settings for categories - the Category Permissions by Aheadworks page, products - the Product Permissions by Aheadworks page, and CMS page -  the CMS Page Permissions by Aheadworks page.

Uninstall Script

Please note: uninstall script works correctly only if the module was installed via Composer

In the backend, the permission settings are divided into:

  • General settings of the extension which allow you to set all necessary conditions for managing the elements of a store catalog, including static pages (further, these settings will be used as default);
  • Individual settings which allow you to set permissions for each store catalog element individually (categories, products, CMS pages);
  • Mass settings which allow you to set/delete permissions for the unlimited number of categories, products and/or pages.

The command to run the uninstall script:

Icon

Note for a developer:

To use the uninstall script in the standard workflow, see Magento\Setup\Console\Command\ModuleUninstallCommand::validate(). The function should return an empty array for correct further processing. You can simply comment out lines 319-338.


 Frontend Visualisation

The extension, in fact, starts working right after the installation. You just need to configure it in accordance with your preferences. When the configuration stage is passed, you can start managing the store catalog visibility. Note, that the extension frontend is the result of the extension configuration in the backend.

 

Product Page

Need Customization?

Magento 2 Custom Development Services by Aheadworks


You can always find the latest version of the software, full documentation, demos, screenshots and reviews at http://ecommerce.aheadworks.com  
License agreement: https://ecommerce.aheadworks.com/end-user-license-agreement/   
Contact Us: http://ecommerce.aheadworks.com/contacts/ 

Copyright © 2018 aheadWorks Co. http://www.aheadworks.com 



  • No labels