Categories


Archives


Recent Posts


Categories


Consistant Config Node Naming

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

When you first have that ah-ha moment with the Magento System Configuration creator, your first instinct is to start creating a lot of extra configuration values for your features and modules. It’s easy enough to think “hey, I’d like to add another email address to the Store Email Addresses section”

There’s nothing wrong with doing this, but you’ll need to keep the xml node naming convention the same

trans_email/ident_sales/name
trans_email/ident_sales/email

trans_email/ident_YOURTYPE/name
trans_email/ident_YOURTYPE/name

That’s because certain parts of the config will loop over each of the trans_email entries to get a list of possible email recipients. Check out System -> Configuration -> Catalog -> Product Alerts -> Alert Email Senders

for an example. The values for this select are generated by splitting the group name by underscore, resulting in a string like one of the following

support, sales, custom1, custom2

Then, the PHP code that sends the email reconstructs the PHP path with code something like this (exact code varies from section to section)

$config path = 'trans_email/ident_' . $value . '/email';

So, if you name your config node something like

trans_email/awesome_person/email

That means Magento would store the value person, and then attempt to create a confirmation node trans_email/ident_person/email. This node wouldn’t exist, and your email wouldn’t get sent.

Email isn’t the only system that does things like this. So, if possible, it’s best to keep your own configuration values in their own tabs/sections. However, if that’s not possible of feasible (go client services), take the time to look at the names of the other configuration fields and groups and if you detect a pattern, make sure you match it.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 17th July 2011

email hidden; JavaScript is required