Magento2 – Write Custom Mysql Query (Without Using Model)

How to create custom “Duplicate” buttons for Adminhtml Edit Form and save custom module in Magento2.?

Create file to add button in VenderName/ModuleName/Block/Adminhtml/Edit/SaveAndDuplicateButton.php

Modify _construct function in Edit class to add button in

Add sub-query Magento 2 Collection

Magento 2 how to add new column in quote_item table?

You can add column like this


Add Date picker in phtml file Magento 2 Admin

For Datepicker :

For Date Time Picker :

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.