Archive for the ‘Magento Development’ Category

Magento Modules and the Community

Thursday, October 6th, 2011

MagentoConnect

This post outlines some of our thoughts about the state of the Magento module community, and an idea for how Magento can improve the quality of that community.

Here at Classy Llama Studios we create our own Magento modules every day and have high standards for any module that we write.  These standards include having properly commented code, adhering to Zend programming standards, and having both the code and functionality of the module reviewed before it is released.  Magento is great because, instead of having to write every module that we use, there are numerous other quality development companies whose modules we can draw from for sites that we develop.  Unfortunately, there are a lot of modules out there that are not quality.  Issues with modules that we encounter include poorly written code, SQL vulnerabilities, improper code domain separation, and improper utilization of the Magento Application functionalities.  Some of these modules do not even work.

This abundance of modules often leaves us with a challenging question. Do we recommend this module to our client? If we do, we often have to prepare our clients for the possibility of hours of development, in addition to the module cost, that may be required to make the module safe and functional.  The other option is that we have to take a loss to bring the module to the level necessary for use on our customers’ eCommerce platform.  We love our customers and so it is painful for us to have to make either of these choices when the customer is already paying for the module. Because of this, we have been asking ourselves if there is some sort of solution to the problem of poorly coded modules.

The answer we came up with is twofold.  For now, we can buy most of our modules from the great companies who have earned our trust up to this point; these companies include AheadWorks, Unirgy, and WebShopApps. This alleviates the problem but it does not come close to eliminating it.  We know that there are other developers who write quality modules.  We simply don’t know who they are until we have worked with and reviewed their modules.  We think that Magento itself is the solution to this dilemma.

Even though Magento has had explosive growth since the release of Magento 1.0, it has only been three and a half years since its release.  Since then, Magento has gone through dramatic transitions and upgrades turning it into a much more streamlined and powerful system with numerous features and a massive community.  With eBay’s acquisition of Magento, its future looks even brighter.  Since Magento is so young, however, there are certain features and programs that they have not had or taken the time to develop.  We believe that the development of a Magento module certification would be a great step for the company and the community at large.  Magento has over 4800 modules in Magneto Connect, and we realize that reviewing every one of them would be a massive undertaking, so we think that it should be something that Magento would be best able to facilitate on a voluntary basis.  When Magento certifies a module, that module would receive special recognition and be more accessible to developers and store owners. This would take the burden of code review and repair off individual development companies or users purchasing the modules and put it back on the original developers of the module.  While this could take time to implement, we think that it is an endeavor from which the entire Magento community would benefit.

We’ve communicated this idea to Magento.  Here is a snippet of what we’ve told them: … There are many poor quality developers and modules, and the current system doesn’t provide a system of being able to determine which modules are good, and which are not.  The current Magento Connect is much like the Android Marketplace – thousands of apps, with only a portion of them being high quality.  While we would not like to see the same level of curation as the iOS Marketplace, we would like to see more attention being paid to ensuring that quality modules are promoted, and poor-quality modules are being demoted

We sincerely hope that Magento does this, but regardless of what they do, we love the platform and will continue to support the company and the community to the best of our ability.  We believe that Magento truly is the eCommerce “Platform for Growth” and that it’s many features, programs, modules, developers, store owners, and fans make it a wonderful and enjoyable platform to work with every day.

Tags: , ,
Posted in Development, Magento, Magento Development, Management | 5 Comments »

Wiz 0.9.5: Admin & Developer Tools, Batch Output

Tuesday, October 4th, 2011

The latest batch of Wiz updates includes some useful stuff for developers as well as some administrative features. Included in this bundle of Wizzy goodness is the ability to output any table output in csv, pipe, or tab delimited output. This makes it very easy to utilize Wiz with other commands (or potentially feed information from Wiz back into itself!)

Here is a complete list of the changes in 0.9.5:

  1. The internal configuration system was rewritten to look more like Magento’s own configuration system — using XML files. This isn’t really used heavily yet, but we’ve got some stuff coming in the next few months that will take full advantage of this.
  2. You can now toggle the following “developer” flags from the CLI:
    1. Allow Symlinks (For templates, 1.5.1.0+)
    2. Logging
    3. JS Merging
    4. CSS Merging
    5. Profiler
  3. You can view all of the above configuration values as well with the devel-config command.
  4. Get a list of all registered event listeners.
  5. Get a list of all Models registered in the system and module rewrites.
  6. Scriptable output. Output tabular data in csv, pipe-delimieted, or tab-delimited formats.

If you just want to get going:
Browse on Github
Website / Download

Be sure to read over the Readme file on Github for more information about the added commands!

The Good Stuff

Okay, so the configuration system isn’t a huge deal… but it does open up more potential for 3rd party developers to write plugins that need to store things: usernames, passwords, etc. without having to provide their own storage mechanism. Let’s get to the really exciting stuff!

Developer Configuration

$ wiz devel-config
+---------------------------------+-------+
| Path                            | Value |
+---------------------------------+-------+
| dev/debug/profiler              | No    |
| dev/js/merge_files              | No    |
| dev/css/merge_css_files         | No    |
| dev/log/active                  | No    |
| dev/debug/template_hints        | No    |
| dev/debug/template_hints_blocks | No    |
| dev/template/allow_symlink      | No    |
+---------------------------------+-------+


You can now flip off/on or view the status of each of these independently. Each of these work the same way devel-showhints works.

Developer Helpers

One of the things I’m curious about sometimes is to see what modules are listening to what events. Well, now with a new command, you can see that:

wiz-listener-list

wiz devel-listeners give you a list of the events and the modules and their model/method that is responding to that event.

Often times, I want to know what overrides have been performed by other modules. Now I can see a total picture of what modules provide what models:

wiz-model-list

As you can see, all of the standard models are shown, but you can also see what overrides are performed by all of the modules on the system.

Scriptable Table Output

Finally, of the coolest thing (in my opinion) is the scriptable output. Wiz has a pretty decent table output system that makes it fairly easy for your eyes. However, getting that data out of the table took me far too much time. Enter --batch.

The –batch argument takes the model list we show above and transforms it into:

"Model Name","PHP Class"
varien/*,Varien_*
core/*,Mage_Core_Model_*
core_resource/*,Mage_Core_Model_Resource_*
eav/*,Mage_Eav_Model_*
eav_resource/*,Mage_Eav_Model_Resource_*
page/*,Mage_Page_Model_*
install/*,Mage_Install_Model_*
install_resource/*,Mage_Install_Model_Resource_*
admin/*,Mage_Admin_Model_*

The –batch argument can take one of three arguments: csv, pipe, or tab. csv is the default (as you can see above). Pipe replaces the commas with “|”s and tabs… well, you get the idea. ;) Now you can take your Wiz output and pipe it through grep, cut, etc. or output straight to CSV and load it up into Excel/Numbers/OpenOffice/etc.

Enjoy!

Get Wiz

Browse on Github
Website / Download

Posted in Development, Magento, Magento Development, Wiz | 1 Comment »

The Magento Developer Certification

Monday, October 3rd, 2011

MagentoDeveloperPlus

As many of you know, Magento recently announced their Magento Developer Certification program.  As one of the few partners who have been involved with Magento since it’s inception, we’re especially excited to see this long-awaited program finally being launched.

Due to our depth of knowledge and experience with the Magento platform, Magento invited us to be a part of the Magento Certification Advisory Board. We’ve been involved in the process of writing questions for the certification for the past couple of months.  I want to extend congratulations to one of our Lead Developer’s, David Alger, for representing Classy Llama on the Advisory Board.  His contribution to the development of the certification has been substantial – he even won the award for completing the most number of objectives at a one-week onsite question-writing session.

The certification is going to be beta-launched at the Innovate conference at the middle of this month and will be announced to the public later this year.  We have four developers who will be at the event and taking the certification.

Posted in Magento Development | 4 Comments »

Add Custom Layout Handles (e.g. Parent Categories)

Wednesday, June 1st, 2011

If you ever need custom layout handles in your local.xml, it’s fairly simple. In this example the observer method will make a new handle for for categories that have children or not, but you can just modify the method to make whatever handles you desire. (I realized after creating this there’s already a handle for anchored categories with no subcategories, catalog_category_layered_nochildren)

First add this to your config.xml in yourcustommodule:

<config>
<frontend>
        <events>
            <controller_action_layout_load_before>
                <observers>
                    <yourcustomtheme_observer>
                        <class>yourcustomtheme/observer</class>
                        <method>addHandles</method>
                    </yourcustomtheme_observer>
                </observers>
            </controller_action_layout_load_before>
        </events>
</frontend>
</config>

Then add this method to your observer:

 
class YourPackage_YourCustomTheme_Model_Observer extends CLS_Core_Model_Abstract
{
    public function addHandles($observer) {
        $category = Mage::registry('current_category');
        if ($category instanceof Mage_Catalog_Model_Category) {
            $update = Mage::getSingleton('core/layout')->getUpdate();
            $fertilility = (count($category->getChildrenCategories()->getData())) ? 'parent' : 'nochildren';
            $update->addHandle('catalog_category_' . $fertilility);
        }
        return $this;
    }
}

Posted in Development, Magento, Magento Development | 2 Comments »

No More Square (White Background) Magento Product Images

Monday, March 21st, 2011

Do you have a site with product images of varying proportions. It can be annoying when Magento gives you that white border to make your product image square. Here’s how customize what color that background is: just add backgroundcolor('000', '000', '000') before the resize() method


<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail',
$_image->getFile())->backgroundcolor('000', '000', '000')->resize(100); ?>" ... />

Better yet, get rid of the background using keepFrame(false):

<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail',
$_image->getFile())->keepFrame(false)->resize(100); ?>" width="100" ... />

Resizing after keepFrame(false) will resize the largest dimension. Don’t forget to delete your image height and width attributes (if need be)!

Here’s (most of) the places you’ll want to change these:

There may be a few more but I bet you can find them. Enjoy your no longer square (white background) images!

Posted in Development, Magento Development | 4 Comments »

Introducing Wiz, a CLI Tool for Magento

Monday, March 7th, 2011

There is a lot of functionality in Magento that is hard to get to or tedious to work with.  There are so many tasks that developers, designers, and administrators do on a daily basis that require time-consuming trips to the Magento backend.  If you happen to want to do more than one of those operations, you end up having do each of those tasks one after the other… if only there was a better way!

It is my pleasure to announce Wiz: a command-line interface tool for working with Magento installations.  It was built to make your work (and subsequently your life) much easier!

Wiz has a whole bunch of great features, but here are some you’re sure to like:

Wiz is a work in progress and hasn’t been thoroughly tested with every Magento version out there.  However, we’ve been using it with Professional and Community Edition installations without any major problems.

Things planned for future releases:

Your feedback and bug reports are welcome!

Update: Some screenshots for the curious…

Wiz: module-list

List all modules, versions, and their statuses without going through the backend.

Wiz: admin-createadmin

Create an admin user without having to touch the database.

Wiz: cache-*

Effortlessly clear, enable, & disable Magento caches.

Wiz: devel-showhints

Enable and disable template hints. Great for theme/skin development.

Wiz: help & sql-cli

Dropping easily into MySQL shell for a Magento install.

Posted in Magento, Magento Development, Management | 12 Comments »

Magento Imagine 2011 – “Best Practices for Debugging Magento” assets

Tuesday, February 8th, 2011

I just finished giving a presentation at Magento Imagine conference.  I’m posting the link to the Powerpoint and the video I embedded in my presentation:

http://bit.ly/fqwvlD

Cheers!

Posted in Magento Development | 11 Comments »

Get Configurable Super Attributes

Monday, November 1st, 2010

I wanted to do a check on a configurable product to see if it had a specific attribute. But not just any attribute, a global attribute used to create associated products within the configurable product – a “Super Product Attribute”.

So here ya go:

    $_product = $this->getProduct();
    $_attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product);
    foreach($_attributes as $_attribute){
        var_dump($_attribute->debug());
    }

A little bonus:

The “->debug()” method returns the set of values you can use the get magic method on. For example:

array
  'product_super_attribute_id' => string '263' (length=3)
  'product_id' => string '27' (length=2)
  'attribute_id' => string '80' (length=2)
  'position' => string '0' (length=1)
  'product_attribute (Mage_Catalog_Model_Resource_Eav_Attribute)' => 
    array
      'attribute_id' => string '80' (length=2)
      'entity_type_id' => string '4' (length=1)
      'attribute_code' => string 'color' (length=5)
...

So var_dump($_attribute->getAttributeId()); will return string ‘80′ (length=2). Just use “get” with the Capitalized Label, getProductAttribute(), getProductId(), getPosition(), etc. Enjoy!

Posted in Development, Magento Development | 3 Comments »

Magento Developer’s Paradise Summary

Wednesday, October 13th, 2010

I just arrived back in the US after a long weekend at the Magento Developer’s Paradise. We (David Alger and myself) had a great time at the event (see photos of event below). There were a number of different types of attendees: Magento Professional & Enterprise development companies, extension development companies (like Webshopapps.com and Sweet Tooth), freelance developers, and Magento team members. We had opportunity to meet with a number of the european partners (Netresearch,Icommerce,Inchoo, et al) and other developers to share ideas on how to successfully build Magento projects.

#magedev was the official hash for all Twitter posts from the conference. View tweets with that hash here.

Yoav Kutner kicked off the conference with a keynote Sunday morning. Here are some bullet points from his speech:

Some notes from the other talks at the conference:

Thanks to Thomas, Annemarie, and others at Netresearch.de for the great job you did at hosting the event.  Here are some pictures from the event:

Screen shot 2010-10-13 at 2.46.17 AM

Screen shot 2010-10-13 at 2.46.27 AM

Screen shot 2010-10-13 at 2.46.08 AM

IMG_2915

IMG_2913

IMG_2914

IMG_3043

IMG_3059

IMG_3053

IMG_3032

IMG_3021

IMG_3019

Props to David Alger for many of the above photos.

Posted in Magento Development | 5 Comments »

Inspecting the contents of Magento models using debug() vs var_dump()

Saturday, July 31st, 2010

When you are developing for Magento, it is often helpful to see the contents of a Model. A model is a pretty complex object, so when you want to inspect the contents of the model, you generally don’t want to see all of it’s properties – all you’re really wanting to see is the contents of the _data property, which is the array that contains all of the attributes/fields that have been retrieved from the database.

Typically, when inspecting a model, I’ve used one of the following methods:

$model = Mage::getModel('catalog/product')->load(1);
 
# Method #1: This dumps all of the model's property's, including the _data property.
# This results in a lot of superfluous code that I don't need to see.
var_dump($model);
 
# Method #2: This only logs the data in the _data property.  The problem is, if the _data property contains
# any other models, all of the properties of those models will be dumped
var_dump($model->getData());

I recently came across the ->dump() method that is implemented in the Varien_Object class. This method recurses into the _data property of a model and returns an array of the values in the _data property, including the _data properties of the child classes. Here’s the example code:

# Method #3
var_dump($model->debug());

Note: The Varien_Object class is a class from which MANY classes in Magento extend. Most notably, all blocks and all data models extend Varien_Object. If you’ve never looked at the Varien_Object class, I’d recommend scanning/reading through the methods in that class. If you’re too lazy to read through the methods, but want to see what the debug() method does, I’ve included it at the bottom of this post.

Here are three screenshots exemplifying the difference between the different methods (note: the beautifully formatted var_dump output is a feature of the xdebug php extension):

Method 1:

Method 1 - var_dump

Method 1 - var_dump

Method 2:

Method 2 - getData

Method 2 - getData

Method 3:

Method 3 - debug

Method 3 - debug

In case you’re curious to see how the debug() method works, here’s the code from the Varien_Object class:

    /**
     * Present object data as string in debug mode
     *
     * @param mixed $data
     * @param array $objects
     * @return string
     */
    public function debug($data=null, &$objects=array())
    {
        if (is_null($data)) {
            $hash = spl_object_hash($this);
            if (!empty($objects[$hash])) {
                return '*** RECURSION ***';
            }
            $objects[$hash] = true;
            $data = $this->getData();
        }
        $debug = array();
        foreach ($data as $key=>$value) {
            if (is_scalar($value)) {
                $debug[$key] = $value;
            } elseif (is_array($value)) {
                $debug[$key] = $this->debug($value, $objects);
            } elseif ($value instanceof Varien_Object) {
                $debug[$key.' ('.get_class($value).')'] = $value->debug(null, $objects);
            }
        }
        return $debug;
    }

I hope this quick tip helps you program with models more effectively! If you have any questions, feel free to post comments below.

Posted in Magento Development | 3 Comments »

Call us at 417-597-3397, email us at sales@classyllama.com, or use this form to contact us:

  1. (required)
  2. (required)
 

cforms contact form by delicious:days