Follow this steps for override Magento 2 jQuery Widget
If we want to add custom logic in Magento 2 core JQuery widget then first create simple module with required modules files.
1.) Define the sequence in module.xml file which module widget you want to customize for example here we take Magento_Catalog module
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_ModuleName" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
2.) Create requirejs-config.js file in view/frontend directory with code:
var config = {
map: {
'*': {
gallery: 'Vendor_ModuleName/js/galllery'
}
}
};
3.) Finally add gallery.js file in view/frontend/web/js directory with:
define([
'jquery',
'jquery/ui',
'Magento_Catalog/js/gallery'
], function($){
$.widget('custom.gallery', $.mage.gallery, {
// the code you want to override
});
return $.custom.gallery;
});
Now, open Command line in root folder of Magento and run the below commands.
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_US
php bin/magento c:f
php bin/magento c:c
For More Information About Magento 2 jQuery Widget Contact to Magento Services
About us and this blog
We are a digital magento 2 development agency with a focus on helping our customers achieve great results across several key areas.
More from our blog
See all posts
Follow these easy step for adding Slick slider in Magento 2 Custom…
For creating multiple website and stores in Magento 2 you have to…
To create Controller in Magento 2 we need to create basic module…
Magento 2.4.6 will be released in March 2023 and will support PHP8.2…
Magento 2 On Localhost , In this tutorials i am going to…
The simple answer is no - search engine submission isn’t necessary. The majority of…
The answer is simple - inbound linking cannot hurt your search ranking. How…
The importance of anchor text with respect to a linking strategy cannot be overstated.…
No Comments
Recent Posts
- How to add Slick slider in Magento 2 Custom theme March 4, 2023
- How to Set up multiple websites, stores, and store views in the Admin Magento 2 February 27, 2023
- How to Create Controller in Magento 2 February 25, 2023
All Website Tags
Create multiple websites in single magento 2 installation
Magento 2 custom block
Magento 2 custom controller
Magento 2 Custom layout
Magento 2 custom module
Magento 2 custom module development
magento 2 custom template
Magento 2 developer in United Kingdom
Magento 2 development
Magento 2 development in United Kingdom
Magento 2 multistore
Magento 2 multiwebsite
magento 2 root directory.
Magento 2 update services in United Kingdom
Magento 2 version upgrade services
Magento 2.4.6
Magento security
PHP8.2
product slider
Slick
slider
Upgrade to php8.2
virtualhost