Add an Observer for Category Restriction events.xml <?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=”controller_action_predispatch_catalog_category_view”> <observer name=”restrict_category_access_observer” instance=”JJRestrictPageObserverRestrictCategoryAccess”/> </event> </config> Implement the Observer to Block the Category RestrictCategoryAccess.php <?php namespace JJRestrictPageObserver; use MagentoFrameworkEventObserver; use MagentoFrameworkEventObserverInterface;… Continue reading How can I block access to a specific category in Magento 2 for users who are not logged in or belong to a specific customer group using an observer?
Category: Magento
How to remove a category from being displayed in Magento 2 for users who are not logged in or belong to a specific customer group using an observer?*
Step 1: Define the Event Observer <?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_category_collection_load_after”> <observer name=”restrict_category_observer” instance=”JJRestrictPageObserverRestrictCategory”/> </event> </config> Step 2: Implement the Observer <?php namespace JJRestrictPageObserver; use MagentoFrameworkEventObserver; use MagentoFrameworkEventObserverInterface; use MagentoCustomerModelSession as CustomerSession;… Continue reading How to remove a category from being displayed in Magento 2 for users who are not logged in or belong to a specific customer group using an observer?*
How can I remove a specific navigation link (e.g., ‘Hot Sale’) for guest users and for logged-in users who are not in a specific customer group, by overriding the Swissup NavigationPro template in Magento 2?
Step 1: Create the Override Directory Swissup’s menu.phtml is located at: vendor/swissup/module-navigationpro/view/frontend/templates/menu.phtml To override it in your custom theme (JJ), create the required directory: mkdir -p szco/app/design/frontend/JJ/Swissup_Navigationpro/templates/ Step 2: Copy the menu.phtml File Copy the original menu.phtml from the module to your theme: cp szco/vendor/swissup/module-navigationpro/view/frontend/templates/menu.phtml szco/app/design/frontend/JJ/Swissup_Navigationpro/templates/menu.phtml Step 3: Modify menu.phtml to Remove “Hot Sale” for… Continue reading How can I remove a specific navigation link (e.g., ‘Hot Sale’) for guest users and for logged-in users who are not in a specific customer group, by overriding the Swissup NavigationPro template in Magento 2?
Creating a Magento 2 Order Invoice in NetSuite Connector
You can create an invoice in Magento 2 when a fulfillment syncs from NetSuite Connector. To create an invoice in Magento 2 from NetSuite Connector: Log in to app.farapp.com. Select the Magento 2 connector and the relevant account. Go to Settings > Orders. The Order Settings page opens. Click Advanced Options. Check the Trigger Magento to Create Invoices… Continue reading Creating a Magento 2 Order Invoice in NetSuite Connector
Repost a missed scheduled post using commandline in WordPress
If you have access to the server and WP-CLI: Run the following command to trigger the cron job: bash Copy code wp cron event run –due-now This will execute all missed scheduled posts.
Repost a missed scheduled post manually in WordPress
Method 1: Manually Publishing the Missed Post Log in to the WordPress Admin Panel. Go to Posts > All Posts. Find the missed scheduled post (it will be marked as “Missed Schedule” or in the Scheduled status with a past date). Quick Edit or open the post in the editor. Change the Publish date to… Continue reading Repost a missed scheduled post manually in WordPress
Create a Cart Price Rule programmatically via Magento 2’s REST API
1. API Endpoint Use the following endpoint to create a cart price rule: bash Copy code POST /V1/salesRules 2. Request Payload Here’s an example of the JSON payload to create a cart price rule: json Copy code { “rule”: { “name”: “Buy 3 Get Discount”, “description”: “Discount applied when purchasing 3 specific items”, “is_active”: true,… Continue reading Create a Cart Price Rule programmatically via Magento 2’s REST API
How to set a discount in Magento2
Step 1: Create a New Shopping Cart Price Rule Log in to the Magento 2 Admin Panel. Go to Marketing > Promotions > Cart Price Rules. Click Add New Rule. Step 2: Configure Rule Information Rule Information: Rule Name: Enter a descriptive name (e.g., “Buy 3 Get Discount”). Description: Optionally, describe the rule for internal… Continue reading How to set a discount in Magento2
What is codePool?
Code pool is a concept to pull the code in Magento structured format. It is specified when you register new module in app/etc/modules/Company_Module.xml There are 3 codePools in Magento: core, community and local, which reside at app/code/ directory. CodePools: _community: It is generally used by 3rd party extensions. _core: It is used by Magento core team. _local: Local… Continue reading What is codePool?
Undefined array key “frontend” Issue
Got error ‘PHP message: PHP Warning: Undefined array key “frontend” in /home/977869.cloudwaysapps.com/syqfgmwgpb/public_html/vendor/magento/framework/App/Cache/Frontend/Pool.php Screenshot: Solution: ‘cache’ => [ ‘frontend’ => [ ‘default’ => [ ‘id_prefix’ => ’91c_’ ], ‘page_cache’ => [ ‘id_prefix’ => ’91c_’ ] ], ‘allow_parallel_generation’ => false ],