Engine23

Development

GIT Log - Dump to a txt file

I recently needed to gather just a handful of recent commits for a code review.

This actually is very easy to do, with the appropriate flags.

git --no-pager log --stat --since='2014-03-07 04:08:28' > git-log.txt

Now, you can only get the logs since that date/time.

Here is what it would look like:

commit 3551e428e9c214517165c180c306223c53cbdd01
Author: ralbin <russell@russellalbin.com>
Date: Thu Mar 13 11:37:37 2014 -0500 making it so the reduced price is not so dark skin/frontend/default/theme589/css/styles.css | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-) commit e07fd40bc9985164980f16f74864f57ce14ea3d7
Author: ralbin <russell@russellalbin.com>
Date: Thu Mar 13 11:32:51 2014 -0500 applying css fix app/etc/modules/Engine23_Customer.xml | 2 +-
skin/frontend/default/theme589/css/styles.css | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

Display Bundle Product Weight

We had a store where we disabled user configuration of bundle products and set them up the way we wanted as defaults.  That made this much easier, but something similar could be done to update the weight via an ajax call as the configuration is changes.

 

Override the getAdditionalData function in Mage_Catalog_Block_Product_View_Attributes

 

About line 10 you will see where we look for when a bundle product's weight is being set and override it.  Once we catch the right piece of logic, we the weight of the products up and also catch the logic to do the proper formatting logic.  

public function getAdditionalData(array $excludeAttr = array())
    {
        $data = array();
        $product = $this->getProduct();
        $attributes = $product->getAttributes();
        foreach ($attributes as $attribute) {        

Read more

Remembering Apache Restart Command

First off the command to restart Apache2 is:

sudo apachectl -k restart

You can only lookup the command so many times before figuring out a way to remember it. I decided to try to figure out what apachectl was. I found that apachectl is not even Apache2, it's actually a controller for it, or apache controller, or apache ctl .... apachectl. Hopefully it's a bit easier to remember to call the apache controller than apache gobbly goop of letters.

Magento - How to add captcha to the contact us form

Step 1: create the module instantiation xml: app/etc/modules/Engine23_Contactform.xml

<?xml version="1.0"?>
<config>
<modules>
<Engine23_Contactform>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Captcha/>
</depends>
</Engine23_Contactform>
</modules>
</config>

Step 2: Create the folder for our controller and config.xml: app/code/local/Engine23/Contactform

Step 3: Create the IndexController: app/code/local/Engine23/Contactform/controllers/IndexController.php

 <?php 
/*
 * Adding Captcha to Contacts form
 */
require_once(Mage::getModuleDir('controllers', 'Mage_Contacts') . DS . 'IndexController.php');

class Engine23_Contactform_IndexController extends Mage_Contacts_IndexController
{        

Read more

Search Front and Center

We recently looked at the numbers to identify quick ways to improve a customer's conversion rates.  We saw that three times as many visitors were making purchases if they used the search bar than if they didn't.   Some of this can probably be associated to the fact that visitors who already know what they want are more likely to do a direct search for it.   However, we hypothisized it was also the difference between having exactly what a customer wanted right inside the door vs making them find it in the aisle.  The more work to find the product they want, the less likely they are to stick around long enough to find it. Thus we decided to to change around the header to encourage visitors to use the search bar.

 

Before:

Header Before

After:

YourPoolHQ Header After

Read more

Why Magento has become one of the best development platforms

Several years ago, I had heard that a new E-Commerce platform was growing in popularity.  Varien's Magento.  At the time it was community edition 1.3.  I was not impressed to say the least.  Things were awkward, it did not make a lot of sense on why there was SO much abstraction of files and folders.  I found it frustrating that even the original developers did not use their own standards!  What a train wreck!

Fastforward a few months:

I was asked by a local marketing firm to help them with some PHP and without asking too many questions, I said "Yes". It turns out that they had started to build a new commerce site and was sold on Magento by their original developer.  He had quit, and left them high and dry.  This was a huge problem because they were literally weeks from completion and they had no-one on staff who could understand what the heck was going on.  After some Q and A I found they had built their site on Magento 1.3 and could not find ANYONE in Omaha who has experience with it.  I reluctantly said I had poked around with it and found it very complicated (understatement of the year).

I decided that I knew enough to help and this began my quest to fix their issues.  

It turns out that they just needed some cleanup on the checkout, and some basic adjustments to the existing functions.  I was so releaved they did not need some custom extension, because I was NOT able to do much at that point in my Magento career.  

Read more

Magento: Install/Upgrade script setting timestamp

If you need to create a custom table and have a "created at" or perhaps an "updated at" column on your custom table.  That is typically something you want.

In order to get this accomplished you need to have one extra parameter.

<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;

$installer->startSetup();

Read more

Laravel Workbench Migrations & Seeds

Having some fun learning the Laravel framework and was trying to figure out how to do migrations and seeds for workbench packages. In general these are the commands, but read the rest for the particulars.

php artisan migrate --bench="Upshot/Poll"
php artisan migrate:rollback
php artisan db:seed --class="UpshotPollDatabaseSeeder"

Read more

Composer and Magento PSR-0 PSR-4 Autoloading

Alright, so your a modern PHP developer and know that most framework updates are adding composer support out of the box, or are already using it.  Sadly every time you develop in Magento you miss it and Magento’s 2.0 release with composer support is still a ways off. Well you’re in luck! Everyone give Mr. Damian Luszczymak a big hug for making an extension that adds composer support to Magento 1.0.  It adds the composer autoloader prior to Magento’s, so if there are ever any conflicts Magento’s should overwrite them.  Also, he did a great job of implementing it via an observer, so we shouldn’t have upgrade issues.

 

Alright, lets get down to it.  

1) Download the extension at https://github.com/magento-hackathon/Magento-PSR-0-Autoloader and install the files.

2) Add  <composer_vendor_path><![CDATA[{{root_dir}}/vendor]]></composer_vendor_path> to your main local.xml under global

3) Create a vendor folder in the Magento root folder

4) Install composer if you haven’t: https://getcomposer.org/

5) If you have composer installed as a global you can now go to the root Magento folder via command line and run "composer init" with defaults and "composer update".

 

That was very simple, and it works great!