Moving Mac public key to Linux ( CentOS )

Step 1: Find your Mac public key change into your ssh directory in terminal

cd ~/.ssh/

View your public key

cat id_rsa.pub 

Log into your CentOS via ssh and change into your ssh directory

cd ~/.ssh/

Create a id_rsa.pub

vim id_rsa.pub

You can truncate the entire known_hosts file, or just remove the same IP/URL that your trying to connect to, for us, to keep it simple we are just going to truncate the entire file

Read more

Shell script to create multiple versions of current project

I was asked to take a Magento codebase, split it off into 2 different exact copies.

They also wanted each to have updated local.xml with updated database credentials.

Furthermore, they wanted the databases replicated into 2 new ones, that the local.xml would be able to connect to.



while ((ok==0))
    echo "Choose your installation Type:"
    echo -e "\t(p) Probes"
    echo -e "\t(e) Education"
    echo -e "\t(b) Both"
    echo -e "\t(x) Exit"
    echo -n "Please enter your choice:"
    read choice
    case $choice in

Read more

GIT - Checkout remote branch

If you know the branch you want, all you have to do is the following in a console:

git fetch && git checkout remoteBranchName

If you don't know for sure the branch you want, we can easily list all options. Issue the first part of the command

git fetch

This will update your computer with all the code and branches that are on the remote repository. Now we can type the following to get all available options

git branch --all

Or alternately

git branch -a

Now you finish the checkout with

git checkout remoteBranchName

You should see some output that looks similar to Branch remoteBranchName set up to track remote branch remoteBranchName from origin. Switched to a new branch 'remoteBranchName'

Now you're all set to develop on a branch that was created remotely. Don't forget you will have to commit and push (or create a pull request) any changes you make before your teammates can see them, and always remember to pull before you push!

Magento - How many events are fired during a normal page load

I have been doing a bunch of work lately using the event observers system.  This powerful feature of Magento community and Magento Enterprise allows for so much flexibility.  I did find myself kind of stuck trying to find the right event to observe.  My issue was I need to find an event that was after the customer was initialized, but before the Header.php and Header.phtml were brought in.  I needed to change the status of some text based on the customers logged in/out status.

Fastforward to me using the wrong event.  I found, what I thought was the perfect event, customer_session_init.  So, after patting myself on the back for being so smart, I wrote all my logic, and did a happy dance that it was so easy.  Well, after running the code, it turns out that because I was checking if the customer was logged in or not, and if not, AND I had some Header information, I was logging them in...well, sadly that "re-initiallized" the customer session!!!! So, I got the dreaded 

Front controller reached 100 router match iterations

Well, I instantly figured out that I had found a great place to start my check but it was too early in the execution.  I needed a better place, something later in the request flow.  Just to prove things worked  I chose the last "non-generic" event that was fired: controller_front_send_response_after

Read more

Magento - Chrome always asks to enable cookies and not able to log into admin

I recently had a Windows computer, using Chrome get stuck where I could not log into my local magento installation.  I then tried to log into the admin, and it appears as though things worked fine, but the login page reloads, with no error or messaging.  Welcome to COOKIE purgatory.

Turns out that Chrome, being somewhat neurotic, does not like something about the configuration and/or the domain that the cookie is set.  

The fix:  

Step 1: Using some sort of method to update the mysql database ( adminer, phpmyadmin, command line )

Update core_config_data 2 paths and set the values to null

  1. web/cookie/cookie_httponly
  2. web/browser_capabilities/cookies
The following is the raw sql from my instance, you could use a different WHERE clause and use path LIKE 'web/cookie/cookie_httponly' for example, but using ID's is much safer.

Read more

Magento - Limiting US Cities and Territories

I was recently asked if I can build a module that will exclude certain US cities and territories from showing up on the checkout, join, etc. 

The biggest reason is that America Samoa and Armed Forces Africa are never going to be places that customers will be from! 

I had considered selling this as an extension on Magento commerce, but I figured its been a while since I gave back to the community.

After this is installed, the settings are in System->Configuration->General->States Options In the new area: Exclude the selected US States


Magento - Adding to existing getChildHtml elements using local.xml

So, ironically in the past 2 days, I was asked to perform the same task (on two separate projects!)

Basically, in both requests, there is a current template that has getChildHtml and instead of adding a new one to include a new template file, I wanted to be able to just append my to the existing one.

Several benefits, the main one being I am not over-writting a core template file that may change during upgrades...and there is existing placeholders on the template that I can add my custom data inside.

This one that I will be showing is the customer accout create form.

That form had all the elements I wanted, except in this case they wanted to add some extra content.

Now, yes,  I could of just got the main template, app/frontend/base/default/template/persistent/customer/form/register.phtml and put it in my theme, and just hard coded my new content.  BUT that is not the magento way, that does not allow for fallback, and that means that if we switch themes I need to remember to move that code, and hope that things dont change or break in the future.

The better way, just add your new section via xml!

I struggled with the exact syntax until I remembered I did a similar thing when I added captcha to a magento website earlier.

Read more