Adding a fall back theme to Magento

When working with a Magento site with multiple themes, we often want to override some of the design on every site. Magento doesn’t recommend modifying the base/default theme, as changes would get overridden by an upgrade. It is fairly straightforward to add an additional fallback theme. Add a rewrite to a magento extension on the Mage_Core_Model_Design_Package class and modify the _fallback method. This will add an additional fallback theme, base/common that will be used before the base/default theme.

SQL Tree Structure

While building a productivity tracking application for my employer, I identified the need for a tree structure to track human and work hierarchies. The project included the special requirement that history needed to be preserved. It had to track employees or work moving from one place to another in the tree and be able to perform complex queries on the tree.

I based my work on the adjacency list model. We use two tables to store our data:
u_unit – stores the names of all the elements of the tree
uu_unit_unit – stores the connections between the elements and their valid dates

Afterwards, the data is compiled into a single table via a stored procedure. The compiled data looks like the following:

id         name             type            parent level path                start    end
1          Company          root                   0      1                  1/1/2000 12/31/9999
2          Director A       director        1      1      1/2                1/1/2014 12/31/9999
3          Manager A        manager         2      2      1/2/3              1/1/2014 12/31/9999
4          Manager B        manager         2      2      1/2/4              1/1/2014 12/31/9999
5          Supervisor A     supervisor      3      3      1/2/3/5            1/1/2014 8/31/2014
5          Supervisor A     supervisor      4      3      1/2/4/5            9/1/2014 12/31/9999
6          Supervisor B     supervisor      3      3      1/2/3/6            1/1/2014 12/31/9999
7          Supervisor C     supervisor      4      3      1/2/4/7            1/1/2014 12/31/9999
8          Employee A       employee        5      4      1/2/3/5/8          1/1/2014 8/31/2014
8          Employee A       employee        5      4      1/2/4/5/8          9/1/2014 9/30/2014
9          Employee B       employee        6      4      1/2/3/6/9          1/1/2014 12/31/9999
10         Employee C       employee        7      4      1/2/4/7/10         1/1/2014 12/31/9999
11         Employee D       employee        7      4      1/2/4/7/11         1/1/2014 12/31/9999
12         Employee e       employee        7      4      1/2/4/7/12         1/1/2014 3/31/2014
12         Employee e       employee        5      4      1/2/3/5/12         4/1/2014 8/31/2014
12         Employee e       employee        5      4      1/2/4/5/12         9/1/2014 12/31/9999

The path of the tree table makes it easy to sub-select from the tree, example:

-- Select all direct & sub reports to 'Manager A' on 2014-05-15
select * from ut_unit_tree
where '2014-05-05' between ut_start and ut_end
and ut_path like '%/' + cast((select u_id from u_unit where u_type = 'manager' and u_name = 'Manager A') as varchar) + '/%';

The heart of the code is the rebuild_ut_tree procedure, which recursively adds each level of the tree one by one, until there is no more elements to add:

begin transaction;
delete from ut_unit_tree;
insert ut_unit_tree (ut_u_id,ut_name,ut_type,ut_parent_u_id,ut_level,ut_path,ut_start,ut_end)

select u_id,u_name,u_type,null,0,u_id,'1/1/2000','12/31/9999' from u_unit where u_type = 'root';

SET @x = 0;

WHILE @X < 8

insert ut_unit_tree (ut_u_id,ut_name,ut_type,ut_parent_u_id,ut_level,ut_path,ut_start,ut_end)
select u_id,u_name,u_type,uu_parent_u_id,@x+1,ut_path + '/' + CAST(u_id as varchar(5)),
(case when ut_start > uu_start then ut_start else uu_start end),
(case when ut_end < uu_end then ut_end else uu_end end)
inner join
uu_parent_u_id = ut_u_id
inner join
uu_child_u_id = u_id
ut_level = @X;

SET @x = @x + 1;
END; -- while
DELETE FROM ut_unit_tree WHERE ut_start > ut_end;


Attached is a zip with the database schema (T-SQL), sample data and queries.


LOLClass is a custom CMS for gaming videos and other content, initially focusing on League of Legends, with additional games planned. The CMS was built from scratch on the Yii platform. It includes content internationalization, complex data types, page widgets, social networking, user registration and subscriptions, automated billing and optimized indexing of content.

I played the role of lead programmer during the initial project phase, laying the foundation for all of the site’s major features. I worked with four other developers over a 4 month period. I assigned tasks, completed code reviews and merged incoming code. The CMS was carefully designed for scalability, as LOLClass is a relatively high traffic site. The system supports parallelization in web workers, database and cache.

Site screen shots are pending the new site’s official launch.


Borderjump is a platform to facilitate international e-Commerce, by calculated landed costs, including duties and taxes, fraud management, and shipment tracking. They provide a Magento extension and a complete API for custom integrations. Most recently, Borderjump can integrate with Japanese e-tailer giant Rakuten, by fetching orders, manage stock and settle costs and taxes associated with the order. I am the primary development contractor on the project. In addition to maintenance and support of their existing systems and the Magento extension, I have added new capabilities, such as the Rakuten integration.

Cheerwine Facebook Forums

Cheerwine needed forums for their Facebook fan page. We built an entirely custom system that allows their school representatives, called Czars, apply for access. Admins can grant it and assign schools. Once assigned, a Czar can moderate and create new forum topics for their fans to respond to and share on Facebook. This Facebook App is totally integrated with facebook, pulling in various user information such as their avatar and usernames. It also automatically pulls in the bio and avatar of each Cheerwine Czar.

Visit online:

Continue Reading

ChoiceSpine App

Choicespine is a private IOS order creation app that can be used on the go without a data connection. Orders are sent in batch once a connection is available. The app also featured an adaptive layout so that it can be used on both iPhone and iPad, as well as a “by finger” signature widget.

Continue Reading

Vowel Movement

Vowel Movement is an IOS game that I developed for a client. The game consists of layer out letter tiles into a crossword puzzle grid to achieve the most points possible. It is called vowel movement because vowels can reorganized on the board at anytime to get more points, unlike consonants, which cannot be moved once played. The game is no longer available on the App Store.

Continue Reading