Q: A custom frontend controller will extend which one of the following classes?

All Action Controller need Mage_Core_Controller_Front_Action as an ancestor.

The best example of this in action is a simple HelloWorld module that is configured with routes and has a Create Action Controller for the routes.

Directory Structure:


We need a configuration file (PATH: app/code/local/nodwell/Helloworld/etc/config.xml):


and a modules file to activate our module (PATH: app/etc/modules/nodwell_Helloworld.xml):


Now, the module exists, and we can begin to add the code to make it do stuff. We need to configure a route in the config.xml. The route turns a URL into an Action Controller and a method. In our case, it will act on URLs that start with /helloworld, as in http://magento.nodwell.net/helloworld/*. So, add a frontend routers section to the config.xml:


Now, we create the actual Action Controller (PATH: app/code/local/nodwell/Helloworld/controllers/IndexController.php):

class nodwell_Helloworld_IndexController extends Mage_Core_Controller_Front_Action {        
    public function indexAction() {
        echo 'Hello Index!';

Code Generation in Magento 2

When and Why Does Code Get Created in /var/generation?


Code generation can be triggered in two ways:

1. On the fly – when the system tries to autoload a class, if it doesn’t find it, it generates it. (slower)

delete the MAGENTO_ROOT/var/generation directory

2. Command-line – process goes through the system, inspects the code, and generates the necessary classes it might need. (speedier)

run the magento setup:di:compile command from terminal on web server

Code Generation did not exist in Magento 1. In Magento 2, code generation is deployed to support a number of core concepts.

The system generates several class types – the 3 most important are Factories, Proxies, and Plugins.


Factories are used to instantiate objects that cannot be injected automatically, objects that it doesn’t make sense to create with a generic mechanism, such as those which contain data from the database.

  1. Developer declares a dependency on factory in constructor ($productFactory)
  2. Object manager injects this dependency
  3. Developer can access create() method (the only method in factory object) to create as many Product instances as he wants.

The purpose of factories is to delegate object instantiation to object managers.


Magento 2 uses the object manager to create all the dependencies and allows only one type of dependency injection: constructor injection. Thus, you cannot instantiate an object without passing all the dependencies as they are required. Proxies allow you to pass in optional dependencies.

Developer never touches PHP files to use proxy, only inside the di.xml

Whenever any proxy method is called for the first time, the original instance gets created with all its dependencies. The purpose of a proxy is to delay creation of an instance (and its dependencies) until the very first usage.

Plugins (Interceptors)

Plugins are the primary customization mechanisms for Magento 2 which replace class rewrites. Plugins allow you to hook in and do something before, after or around any public method of the application.

  1. Developer writes a plugin class depending on the requirements
  2. Developer registers a plugin in di.xml

The system generates the interceptor class. The generator tool will generate only the methods that you rewrite.

Installing Magento 2 with Composer

If you’re looking for something amusing to do some rainy afternoon, don’t install Magento 2. 😉

Before You Start

Before you start your installation, make sure your web server meets the minimum system requirements:

  • A Linux x86-64 operating system
  • 2GB of RAM
  • Composer (latest stable version)
  • Apache 2.2 or 2.4 with mod_rewrite enabled or nginx 1.8 or latest mainline version
  • MySQL 5.6 (MariaDB and Percona are compatible)
  • PHP 5.6x, 5.5.22 or higher, 7.02 up to 7.1.0 but not 7.0.5 – required PHP extensions:
    • bc-math
    • curl
    • gd, ImageMagick 6.3.7 or both
    • intl
    • mbstring
    • mcrypt
    • mhash
    • openssl
    • PDO/MySQL
    • SimpleXML
    • soap
    • xml
    • xsl
    • zip

For more information, see the magento dev docs.

Magento Access Keys

My Account
My Account Marketplace Tab – Click on My Access Keys link

Next, you need to log in to your account on the Magento Marketplace and request a key pair to authenticate the install with. It’s free. Sign up.

Your Magento Access Keys Screen
Your Magento Access Keys Screen

On the next screen, click the button to Create a New Access Key and give it any name you like. Leave this window open because you are going to need the Public Key and Private Key that it generates when you create a new access key.

For more information, see the magento dev docs.

Install Via Composer

In a terminal, on the command line, in the root of your magento 2 directory, enter the following:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition

It is going to prompt you for a username. Enter the Public Key you got from the Magento Marketplace. It will prompt you for a password. Enter the Private Key you got from the Magento Marketplace.

Install Via Composer
Install Via Composer

Install Sample Data

Enter the following two commands in the terminal from your magento2 root directory:

php bin/magento sampledata:deploy
php bin/magento setup:upgrade

If you are really, really inordinately lucky, you now have a working magento 2 site with sample data installed. Most likely, though, you got some errors when you tried to install the sample data, and you’re stuck.

If you try to install sample data, and get a list of packages that “could not be found in any version,” don’t panic, there’s a GIT work around.

Install Sample Data via Git

Since the above method rarely works for anyone, there is a way to install the sample data from github. Create a directory anywhere outside your web root and clone the GitHub repo using this command:

git clone https://github.com/magento/magento2-sample-data.git
Clone the repo
Clone the repo

Next, run the installer script

php -f /dev/tools/build-sample-data.php -- --ce-source="/var/www/"

After that finishes, go to your magento root, and run the updater:

bin/magento setup:upgrade

and you will see the sample data start to be installed. This process will take quite a while.

Almost Finished

Clear the cache (and fix file permissions if needed) and you should see all the sample data in the front and back ends now.
Again, if you’re lucky, your store is ready to rock and roll.
You might have an issue where your css files are not loading.

CSS is missing
CSS is missing

From your web root, recreate the static content:

php bin/magento setup:static-content:deploy

Then, reindex

php bin/magento indexer:reindex
Reindexing Magento
Reindexing Magento

Check that the folder permissions are 755 in the pub folder and its subfolders and delete all the files and folders in var/cache, var/page_cache, and var/sessions and go reload your site.

Magento 2 Sample Data
Magento 2 Sample Data

Garden Report 06-01-15

garden report 06-01
The garden looks so lush and full right now.

2015-06-01 14.23.15
The sweet peas are putting on pods.

2015-06-01 14.23.27The eggplant is flowering.

2015-06-01 14.23.36The little cherry tomatoes are bursting out on the tomato bush now.

2015-06-01 14.24.11The zucchini is blooming and putting on little squashes.

2015-06-01 14.24.18Cantaloupe is starting to grow up the trellis.

2015-06-01 14.26.14The first of the little cucumbers are starting to grow.

Class Naming Conventions and the Autoloader

The way classes are named in Magento was taken from the Zend Framework, upon which Magento was developed.

Class names are standardized depending on their location on the file system. This standardization enables automatic class loading. The Magento autoloader is built in /app/Mage.php. Because class names are directly related to a specific path in the file system, the autoloader allows developers to include them without using include_once or require_once. A class named Mage_Page_Helper_Data, for example, would be found at /app/code/core/Mage/Page/Helper/Data.php

The Main Magento Design Areas

Magento Design Areas
Magento Design Areas
All UI files are contained in three main Magento design areas.

  • /install – files controlling display during installation process
  • /adminhtml – files controlling display of everything you observe while working in the admin panel.
  • /frontend – files controlling display of everything you observe as a customer of the store

Garden Report 04-29-2015

Japanese Boxwood

I was excited to see the really tall flower in the front quarter circle bed nearly ready to bloom. The bud is just about to burst open. And one of the asparagus has come up! I was beginning to be afraid they might not have survived the planting. On the side of the house there is a really beautiful pair of Japanese Boxwood in bloom.

  • The Garden, April 29, 2015
    The Garden, April 29, 2015
  • Radishes
  • Beets
  • Carrots
  • Japanese Boxwood
  • Asparagus
  • Big Flower
  • It's so exciting to see how green and vibrant everything is.
  • The radishes are really getting big now.
  • These are the beets. They are starting to look more like plants.
  • The carrot sprouts are starting to really look like carrots now. They're growing nicely, in spite of the fact that the maple tree is attempting to drown them in seeds.
  • These bushes on the side of the house are absolutely stunning. I think they are Japanese Boxwood, and the flowers are so bright and the color so intense, that they look fake.
  • One (of the 36) asparagus crowns I planted in the front bed has finally sprouted!
  • This really tall flower is about to bloom!