Wherein I attempt to explain the theme fallback system to a Magento newbie on Stack Overflow
Wherein I attempt to explain the theme fallback system to a Magento newbie on Stack Overflow
astormOne Line Observers
I’ve started creating single line observers like this <?php class Mycompany_Mymodule_Model_Observer { public function someMethod($observer) { Mage::helper('mycompany_mymodule/observer') ->someMethod($observer->getCustomer()); } } The logic is punted to a helper class. This way the helper receives only the objects it needs [...]
astormController _redirects are Not Immediate
Magento Version: 1.5.1 If you’ve spent anytime with the Magento core controllers, you’re probably aware you can kick off an HTTP redirect with something like $this->_redirect('catalogsearch/term/popular/'); There’s two things about this you should be aware of. The _redirect method does not automatically halt [...]
astormYour local.xml Layout File Might not Win
When explaining the local.xml Layout file, you’ll hear Magento veterans (myself included) explain that local.xml is loaded last, so the updates there always “win”. This is true, to an extent, but there’s one big caveat to keep in mind. Layout Update XML Fragments are loaded and applied in order, by handle. That [...]
astormSQL Headquarters
There’s more sophisticated ways of logging and profiling SQL in Magento these days, but sometimes it’s still easier and quicker to drop down to the abstract Zend adapter and log your queries with a few discrete calls to Mage::Log Almost every INSERT, UPDATE, SELECT, and DELETE goes through the methods in [...]
astormWe have an extension that uses Ajax to change what shipping rates are shown in a weekly date/time grid @webshopapps, in response to my question “Hey magento people, are there are any extensions (free/paid) that add Ajax features to the checkout page?”
astormCheckItOut @andkorolyov, in response to my question “Hey magento people, are there are any extensions (free/paid) that add Ajax features to the checkout page?”
astormSome people in the Magento Community are getting antsy about the eBay acknowledgment. As with anything that’s out of my control, it’s a hope for the best, plan for the worst situation.
astormPHP Patterns in Magento
In many programming languages, especially the less strictly typed ones, a common coding pattern starts to emerge. $thing = $this->getSomeThing(); if($thing) { //do something with the thing } Without a compiler to catch methods returning what they shouldn’t, a developer is forced to sanity check return values from methods before [...]
astormMagento Custom Form Validation
Magento’s form validation seems scary at first, but using it is actually quite easy. First, create for your form. <form action="<?php echo $this->getUrl('/some/route/thing');?>" id="theForm"> <input type="text" name="foo" id="foo" /> </form> Next, run this bit of javascript to turn your plain old form [...]
astormSafari Keeps Showing “Please Enable Cookies” Page
Lots of kind souls helped me out on Twitter with this one. Some versions of Safari are stricter about setting cookies than others. Also, Magento sets the full cookie domain and path as well, which is where weird cookie bugs can lie. If you’re having trouble setting your session Magento (i.e. “Please Enable Cookies, you [...]
astormEditing Email Templates
Magento Version: 1.5.0.1 I’m not sure when this feature was added. It’s there in 1.5.0.1 and might be in previous version. The phtml template file for your system emails are located in app/locale/en_US/template/email/ However, you don’t want to edit these files. Instead, go to System -> Transactional Emails This UI [...]
astormMagento Quickies
As with most successful blogs, my success here has led to success elsewhere. I have three or four half finished articles that are going to have to stay that way for a few more months.
astorm404 Debugging
Magento Version: 1.4.2 I’ve found that most of my route based 404 problems in Magento can be traced a misnamed controller file and/or class. Adding some debugging to the standard router’s _validateControllerClassName method often point to the problem. In 1.4.2 you can find this file here.
astormsales_model_service_quote_submit_before, sales_model_service_quote_submit_success, sales_model_service_quote_submit_after. All of these are in Sales/Model/Service/Quote.php in submitOrder() method. Zoran Lazarevski, when asked What event(s) are you using to “do something” after checkout/order-creation, regardless of method?
astormsales_model_service_quote_submit_before, sales_model_service_quote_submit_success, sales_model_service_quote_submit_after. All of these are in Sales/Model/Service/Quote.php in submitOrder() method. Zoran Lazarevski, when asked What event(s) are you using to “do something” after checkout/order-creation, regardless of method?
astorm