Create CMS pages programmatically in Magento2

March 2, 2017 Iyngaran Iyathurai 0

Creating a CMS pages in Magento is simple as navigate to Admin Panel -> CMS -> Pages. But while you developing your extension you might need to create a Magento CMS Page programmatically. Here is the way how you can achieve it:  

That’s it!. Clear cache and upgrade magento.


Magento 2.x. Update/add cms static block programmatically.

March 2, 2017 Iyngaran Iyathurai 1

To update cms static block for particular store programmatically you can use following code.


Magento 2: Add a CMS Static Block via XML Updates in you homepage

March 2, 2017 Iyngaran Iyathurai 0

These are the steps to add a CMS Static block to your homepage using XML Updates in XML files. Go to the Admin Panel > Content > Blocks Click on “Add new Block” Create your custom block, make sure that the option “Enabled” is checked and save it. In the project code, go to app/design/frontend/[VendorName]/[themeName]/ and add the following file app/design/frontend/[VendorName]/[themeName]/Magento_Cms/layout/cms_index_index.xml

 NOTE: You can use “before” or “after” to place the block as you […]

Create Magento 2 admin user from shell/terminal

December 5, 2016 Iyngaran Iyathurai 0

Thankfully, Magento 2’s newly introduce CLI (command-line interface) allows you to do this without writing any code. Here is an example of how I would execute this command to create a new administrator. Go to your magento bin folder in terminal, Example – cd <your Magento install dir>/bin and run the following command.


Magento: Getting Skin Urls in transactional emails

September 8, 2015 Iyngaran Iyathurai 0

A problem I have come across before is when I want to include an image within a transactional email, using:

 The problem being that by default, the transactional emails will look in the skin folder for the admin area in the base package. However if your storing images in the frontend skin folder for your package/theme, you need to be able to provide this CMS syntax additional information. You can specify the area, package […]

Split time slots between start time and end time in PHP

July 8, 2015 Iyngaran Iyathurai 8

Creating time between start time and end time in interval of 30 Minutes in PHP

Test it now


How to add a new field to Magento configuration?

July 1, 2015 Iyngaran Iyathurai 0

In this example, I am going to add a new field under the Configuration -> CATALOG -> Catalog -> Product Alerts, The filed name is “some text” and it is a select box with Yes, No Options. To do that, we need to add/edit system.xml in our custom module. Here is the XMl to add a new filed.

Thats it, Clear the Magento cache and test it.  You will be able to see the […]

Calculate distance between two locations by Latitude and Longitude

May 22, 2015 Iyngaran Iyathurai 0

The following code returns the distance between to locations based on each point’s longitude and latitude. Passed to function: lat1, lon1 = Latitude and Longitude of point 1 (in decimal degrees) lat2, lon2 = Latitude and Longitude of point 2 (in decimal degrees) unit = the unit you desire for results where: ‘M’ is statute miles (default) ‘K’ is kilometers ‘N’ is nautical miles   PHP Code


Reference Links  

How to Manually Add a WordPress Administrator to the Database using SQL Queries

May 19, 2015 Iyngaran Iyathurai 0

In a recent WordPress hack attack which we worked on and recovered, the owner’s WordPress administrator account was demoted to a user role, therefore the owner did not have any control over the WordPress installation. To regain back access to WordPress, we manually created a new WordPress user with an Administrator role directly in the database.   In this tutorial I will show you how to manually create a WordPress administrator in the WordPress database […]

Bulk delete pending wordpress comments

April 10, 2015 Iyngaran Iyathurai 0

Been under a comment spam attack lately? Or you just did not have time to delete spam comments over several months and you now have hundreds of spam comments that needs be deleted page by page using the wordpress admin? Don’t worry, there are a couple of easy ways to bulk delete pending comments in your wordpress blog. Method 1: Direct MySQL Query If you know yourself around phpMyAdmin and MySQL queries, just run this […]