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…