Checkout: Trigger updates on country/region changes

You can create a mixin for Magento_Checkout/js/action/set-shipping-information and use that to add an event listener to the shipping address select fields (or any other field for that matter). Under you theme root folder create a requirejs-config.js file declaring the mixin The create the mixin file set-shipping-information-mixin.js under the declared Theme_Vendor/Theme_Name/Magento_Checkout/js/action folder with the following content:

Read more

How to run SQL commands in magento

Although I wouldn’t recommend running accessing the database “directly” via SQL commands, it might be useful as a last resource to do so. But, how would one be able to implement it? By using the ResourceConnection class in \Magento\Framework\App we would be able to establish a connection to the database and get an object that implements the AdapterInterface defined in[…]

Read more

Useful FREE tests you should run on your website

#1 Favicon To check if favicon is correct and look good on iOS, Android, Windows… well, basically everywhere run your website’s url through https://realfavicongenerator.net/favicon_checker.This is an awesome online tools that will check all browsers, platforms and technologies for you and better yet will allows you to fix them! Yes, it will create all versions of your favicon for all situations[…]

Read more

How to optimize the Magento 2 queue consumers

If your are having problem with the magento 2 cron jobs and it gets stuck or long-running you can try to optimize the way magento handles the queue consumers. By default consumers should continue polling for messages if the number of processed messages is less than the max_messages value (which can be specified in the env.php file). This is actually only[…]

Read more

Content Security Policy problem when changing store views in Magento

I recently came across a problem with the store view switch caused by the default content security policies used by default. When using different domains on store views you might notice that the redirect will not work when you chose a different store view in the language dropdown. This is caused by the content security policies that magento, by default,[…]

Read more

How to make magento mobile menu collapse on all levels

By default, magento mobile menu is set to collapse only at the top level and not on all levels. To overcome this default feature one must override the _toggleMobileMode function that is implemented in the lib\web\mage\menu.js file.Overriding or extending javascript functionality in magento should be done using mixins. A mixin is a class whose methods are added to, or mixed in, with[…]

Read more

Minimize Magento downtime when deploying changes in production mode

Here are a few suggestions to minimize downtime on Magento, whenever you need to deploy changes in production mode. Changes on phtml template files in the child theme(no downtime) All templates are updated in folder var/view_processed (no need to delete it first) Changes in less, css, js files in the child theme(no downtime if css and js are served from[…]

Read more