Printing a JSON array from Magento 2.4.4

Usually, the JSON can be printed using a simple logger but from Magento 2.4.4 onwards this will not print the array. For that, we have to use $logger->info(print_r($params,true)); (print_r($jsontobeprinted, true)) Var_dump can be also used for printing the contents in the variable.

Published
Categorized as Magento

How to configure qty to use decimal quantities in magento 2

In some Cases we may need to use qty to use decimal in our store so inorder to enable this we have two provisions to select that to each product based or we can totally declare to allow decimal for qty values. Display settings for each individual productGo to the following link : Admin panel… Continue reading How to configure qty to use decimal quantities in magento 2

Adding Remember Me To Magento Sign In and Sign Up Pages

Magento has default feature to keep the user logged in to a particular browser and for custom design it may not be visible . Add the following to custom module layout to Magento Customer>layout>customer_account_login.xml and customer_account_create.xml Turn on the persistence option in back end.

Method to add custom JS validation rule in Magento 2

Add requirejs-config.js file to the following location: app/code/[Vendor]/[Module]/view/frontend/requirejs-config.js Copy file vendor/magento/module-ui/view/base/web/js/lib/validation/rules.js to app/code/[Vendor]/[Module]/view/frontend/web/js/lib/validation/rules.js Where you can add the custom validation code as following: That’s it. Overriding the inbuilt JS also done in the same,if you are using a custom , create a folder with the same naming pattern in the vendor folder structure and paste… Continue reading Method to add custom JS validation rule in Magento 2

Magneto Event before customer login to clear carts for logged out customers

Here the art will be updated with custom pricing for the customer when the customer logged in. With the help of a observer it can be done:- The event used to trigger the Observer will be :- controller_action_predispatch_customer_account_loginPost Observer will contain the repository of Quote,Customer section and cart.