Tips and Tricks: Developing with Magento

Things you Should Know Before Developing With Magento

—————————————————————-

Now being more experienced with Magento we definitely feel the need to share our findings with the masses. We only wish we knew these things prior to trying to the hack the crap out of magento to make it do what we want.

Turning on Template Path Hints
If you’re new to Magento you will realize that it is quite a hassle to understand the logic behind the file structure and block structure of a magento layout when trying to customize your storefront. There is a very under-publicized built-in magento feature that we’d like to share with you that should help you on your journey. Magento actually has the ability to display hints showing where the different files of your layout is contained so that you can edit it.

Magento's Built-In Template Path Hints

To achieve this, Follow these simple steps…

  • Log in to your administration panel. Go to Sytem > Configuration.
  • From the left navigation column on top there will be “Current Configuration Scope”. In the drop down menu select “Main Website”
  • Then navigate to Developer > Advance, also in the left navigation column.
  • Under “Debug” you’ll see Template Path Hints. Select Yes and click the Save Config button.

Now when you navigate to your storefront you’ll see a bunch of red boxes displaying the underlying structure of the pages regarding templates and blocks.

Note: This should only be used in a development environment, considering this will make your storefront look hideous with big red blocks everywhere.

—————————————————————-

Never edit core files
Problem: When developing with Magento you will find it necesary to edit core files to achieve certain functionality. However, By editting a core file you are basically blocking yourself into a corner. DON’T DO IT! If you ever wish to upgrade at any point in the future you will not be able to because any changes that you have made in the core files will be overwritten. Never fear, there is a way around this.

Solution: The “local” folder (appcodelocal) is your saviour. Say you need to edit the “Shipping.php” file located at “appcodecoreMageShippingModelShipping.php” you can create the same basic directory structure in the local folder and copy and paste the Shipping.php file into the new directory. So, your new “local” Shipping.php file will be located at appcodelocalMageShippingModelShipping.php. You will be able to safely edit anything and everything within that local file and never have to worry about it being overwritten during an upgrade. This trick works because Magento will look for files in a local directory before looking for a file in the core directory.

Note: The above solution will only overpower files that exist within the appcodecore or appcodecommunity directories. Also note that any files within your magento theme (appdesignfrontenddefaultYOURTHEME) or (skinfrontenddefaultYOURTHEME) are not considered core files and you are free to edit them as you please.

These are just to name a few… Follow our blog to read more!

2 Responses to “Tips and Tricks: Developing with Magento”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>