Limit Quantity For the Products With Specific Attribute Magento2

Trying to Limit all the products with having a specific attribute (Yes/No) and others will behave normal. I have used the event in my module my event.xml <event name=”checkout_cart_product_add_before”> <observer name=”quantitylimiter” instance=”Apriljune\Qtylimiter\Observer\CartSaveAfter” /> </event> My Observer File having the following code: <?php namespace Apriljune\Qtylimiter\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\App\RequestInterface; use Magento\Checkout\Model\Session; class CartSaveAfter implements ObserverInterface {…

Create new role with specific ACL rights

I want to create a new admin role with some rights. So I use the following code : $role = $this->roleFactory->create(); $role->setName(‘MyNewRole’) ->setPid(0) ->setRoleType(RoleGroup::ROLE_TYPE) ->setUserType(UserContextInterface::USER_TYPE_ADMIN); $role->save(); $resource = [ ‘Magento_Sales::sales’ ]; $this->rulesFactory->create() ->setRoleId($role->getId()) ->setResources($resource) ->saveRel(); This code works. However, I would like all the subcategories of Sales, not only “Magento_Sales::sales”. For that, I know I…

re-initialise a group collection in block index.php

In my front end (index.phtml) I am calling a method from the Block/Adminhtml/inxex.php which returns the customer groups for a drop-down list. The issue is, the user has just created a new customer group so I need that list to refresh. index.phtml $(“.saveNewCustomerGroup”).click(function(){ console.log(“Saving New Customer Group”); let controllerUrl = “<?php echo $block->getUrl(‘XX/index/SaveNewCustomerGroup’); ?>”; //Use…