Add custom Javascript in Magento admin form

Magento is flexible enough to insert your custom JavaScript code snippets in forms created by your very own Magento modules & extensions.


jQuery Cookies : Get, Set and Delete

Available Options
expires: Define lifetime of the cookie. Value can be a Number (which will be interpreted as days from time of creation) or a Date object. If omitted, the cookie is a session cookie.

path: Define the path where cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire page use path: ‘/’.

domain: Domain of page where the cookie was created.

secure: Default: false. If true, the cookie transmission requires a secure protocol (https).

raw: By default the cookie is encoded/decoded when creating/reading, using encodeURIComponent/ decodeURIComponent. Turn off by setting raw: true.

Ajax Send in Jquery

Whenever an Ajax request is about to be sent, jQuery triggers the ajaxSend event. Any and all handlers that have been registered with the .ajaxSend() method are executed at this time.


How many types of ready states in ajax?

There are 5ready state in ajax. These are as follows

ready state 0: request not initialized

ready state 1: server connection established

ready state 2: request received

ready state 3: processing request

ready state 4: request finished and a response is ready

How to log all Magento 2 SQL queries?

In your app/etc/di.xml, replace the line:



Find-replace text in mysql field

Syntax :


Example :


Magento 2 – How to get value in “core_config_data” table

First you need to include the Magento\Store\Model\ScopeInterface class in your constructor:

Then in your class’ method you can call the following:


How to bind an action after customer login success using Magento?

Add the event to your module’s config.xml file

Now create a model Namespace_Modulename_Model_Observer

Add a customerLogin() method to the class:


Load Customer By Id Magento 2