Get your code audit for your Magento store done by our Magento development team. Get Started.
Most of us follow a regular routine at work day after day. Why do we have to work like machines while machines can actually do it for us? We are meant to work smart and invest our expensive time in making useful and innovative things rather than working hard alone.
Most of us may have a question of How that can be done. Some could even think that automating our work could be expensive. Not Really! Here are some real-time examples of automating your work.
Get our best content on eCommerce and backend operations to optimize your distribution business for profitability in your inbox one time a week.
Person X – Okay, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown. If something – anything – requires more than 90 seconds of his time, he writes a script to automate that. Looking through his “legacy”, You’re gonna love this.
Person X – He sends a text message “late at work” to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron job. The job fires if there are active SSH-sessions on the server after 9.00 P.M. with his login.
Person X – Scans the inbox for emails from “Frank” (a DBA at our clients). Looks for keywords like “help”, “trouble”, “sorry” etc. If keywords are found – the script SSHes into the client’s server and roll back the staging database to the latest backup. Then sends a reply “no worries mate, be careful next time”.
Person X – Another cron job that is set to specific dates. Sends automated emails like “not feeling well/gonna work from home” etc. Adds a random “reason” from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45 am.
Person X – This one waits exactly 17 seconds (!), then opens a telnet session to our coffee-machine (we had no idea the coffee machine is on the network, runs Linux and has a TCP socket up and running) and sends something like sys brew. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.
If you are a Magento developer and if you really like the concept behind this story, you will definitely like the following package. Follow the steps to create a module,
Create folder app/code/Dckap/HelloWorld
Create app/code/Dckap/HelloWorld/etc/module.xml file
Contents would be
Create app/code/Dckap/HelloWorld/registration.php file
Contents would be
We usually do the same kind of work to create a single module with multiple steps every time. Now it is highly simplified. Also, You can create CRUD operation in just 5 mins in Magento.
How To Use It?
Use the following cmd and install it into your system,
wget https://github.com/staempfli/magento2-code-generator/releases/download//mg2-codegen.pharchmod +x ./mg2-codegen.phar # use the command globally on your system sudo mv ./mg2-codegen.phar /usr/local/bin/mg2-codegen
Usage:Cmd: mg2-codegen template:generate
This is a single cmd to generate all the files which are needed to process your functionality
mg2-codegen template:generate module
If this cmd is run, the below actions will be triggered and the module will create a simple one-line cmd step
If you want to see the commands available in this package use the following cmd
List all templates: mg2-codegen template:list