Due to the constant crawling and scrapping of the site by bots, any email addresses shown on the site are prone to spamming. Best way is to avoid showing any email address on site and use a contact us page that triggers a mail to a specified email address. But in case you need to […]
Disable right click
While working on a content heavy site, there was a requirement to disable the right click on the site to avoid direct copy of content. Though there are multiple ways to copy the content and the images from the site, but below is nifty little JavaScript for disabling right click on the site Hope this […]
Caption alignment in wordpress
While working on a WordPress site, I observed the captions shown below images are left aligned. There was a requirement from client to align the caption in centre. I am sharing the script used for aligning the captions, you can use the existing ‘Additional CSS’ feature in the blocks or you can use a third […]
Add breadcrumbs in Magento2
I am going to explain here a way to add a breadcrumb in the default Magento Contact Us Page as an example 1) Create a layout file I have a theme module Decryptweb_Project, so creating a layout file inside it app/design/frontend/Decryptweb/Project/Magento_Contact/layout/contact_index_index.xml 2) Reference the existing breadcrumbs block
Hide admin login in Magento 2
If you are using a SSO to login into Magento admin, you may need to hide the default Admin login functionality. I am mentioning here an important code snippet to hide the admin login form. 1) Create an admin layout For example, I have a module DecryptWeb_Admin, I am going to create a layout file […]
How to not remove items from Wishlist in Magento 2
Updates [April 20,2023] : I have developed an extension for this, please check details from link DW Wishlist Extension. Magento 2 has a functionality that removes the item from wishlist if its added to cart from wishlist. I had a task requirement, it was B2B project so mostly the vendors will buy the same set […]
Encryption and Decryption in Configuration in Magento 2
If you are working with APIs or any secret keys, than you will need to encrypt those keys and store it in Configuration (core_config_data) instead of in a visible form. Below are the steps to do that, 1) Encryption: In your Namespace/Module/etc/adminhtml/system.xml, you need to add a class inside backend_model tag that does the encryption, […]
MySQL Ignore tables
Commands to export MySQL database schema, database with data, selective tables, ignoring tables
MySQL Table Size
Get MySQL table sizes using a query
SQL query results to CSV
Multiple times we get requests in projects to generate reports from database. Below command will be helpful in exporting the MySQL query results directly into CSV (comma separated values) file mysql -h {hostname} -u {username} -p {database_name} -B -e “SELECT code AS ‘Coupon Codes’ FROM salesrule_coupon WHERE rule_id=112” | sed “s/\t/,/g” > /tmp/coupon_code_$(date +%F).csv Above […]