Magento code snippets: mix up customer emails

Sometimes when you working on Magento project you need to have some live data on your local machine to test functionality. So, you need to import live DB. But you don’t want to accidentally send any emails to existing live customers of course.

Here is the mysql query that will mixup a customer emails:

or if you want to preserve customer emails for whatever reason:

Choose one you like. The only difference is a produced emails. First variant produce customer_12345@localhost.dev alike emails. The second one will produce local_real@email.com alike emails to preserve email original values for further work on them.

Please NEVER perform this query on production!

Rating:

Rate this post

Simple Magento .gitignore file

Every time I start a new Magento project I struggle with the git repository setup. After discovering and a few trials, I found a solution that works perfectly with any Magento project. So in this article we’ll talk about how to create a simple Magento .gitignore file.

Here are the basics of setup: Create an empty git repo and then copy Magento files into it.

Let’s start by ignoring the media and var folders.
First, backup original folders and create empty ones instead:

Then move .htaccess files (we need to keep those) from original to the empty folders:

Next add the folders to git and commit:


If you do not have .htaccess in var and/or media folders:

Now add that folders to .gitignore and commit as well:

Make sure you add forward slash here, otherwise you will ignore all media and var folders in the project

Now you can move all folders from the backup folders created earlier back to the root and delete the backups.

Lastly it is time to add the files you want to hide. If you are using a mac, add .DS_Store. If you are using phpstorm. add .idea, continue as needed.

At the end of the day, my .gitignore file looks like this:

That’s all it takes and it works great!

Hope that helps.


Rating:

Simple Magento .gitignore file
5 (100%) 1 vote[s]

Installing ssh2 extension on CentOS with nginx + php-fpm

Easy task if you have an apache server, but what about nginx + php-fpm?

Spent like 40 minutes to figure this out with 20+ tabs opened in Chrome… I have pure nginx + php-fpm install on CentOS, but most tutorials is about how to install ssh2 extension for php, not php-fpm. So the right answer is:

Hope that helps.


Rating:

Rate this post

How to set an active tab after hiding the first one in Magento

Recently I struggled with how to set an active tab after hiding the first one in Magento admin custom module. I wanted to have the view and edit tabs inside the same action, so that when it edits the page both view and edit are shown. When it’s a new action then only the edit tab will be shown (with corresponding title). Sadly, searching the internet gave me zero results, so it was time to make it by myself.

So, I’ve hide view tab when it’s new action:

Result:

Inactive Tab

To set this tab as active you need to add following:

And voila:

Tab set as active!

Hope that helps.


Rating:

How to set an active tab after hiding the first one in Magento
3 (60%) 1 vote[s]

← Older posts

Newer posts →