Category: Programming Quickies

Back in they day, I ran a Tumblr blog named Magento Quickies where I’d post shorter, less in-depth posts about my travels through Magento’s source code. This Programming Quickies categories is the successor to that Tumblr blog. You’ll find all the old Magento Quickies content here, as well as new short posts about programming in general.

This section has its own RSS feed, the old Magento Quickies feed should should be redirecting, and we’re cross posting notifications for new posts over to magento-quickies.tumblr.com. In other words, you shouldn’t need to know any of this, but the duct tape that keeps the internet held together isn’t aging well, so your mileage may vary.

Half FYI for new Commerce Bug users, half shameless plug. This screencast covers the programable access control list features of Commerce Bug. That is, it shows you how you can hide Commerce Bug from certain users (Managers!) and show it to others (Developers!) (Source: https://www.youtube.com/)

This one’s a little un-intuitive. At first. There are times where you’ll want to programmatically check if a customer is confirmed. To do this you’d instantiate a customer object like this $customer = Mage::getModel('customer/customer')->getCollection() ->addFieldToFilter('entity_id','197') ->getFirstItem(); or [...]

Magento Version: 1.5.0.1 Magento’s multiple address checkout doesn’t actually create a single order with multiple addresses. Instead, it creates an order in the system for each different address you’re shipping to.

The Magento object for interacting with customers (Mage_Customer_Model_Customer, alias customer/customer) has three address fetching methods, but you probably only want one of them. The first, and least useful, is getAddressCollection. You might think this method would return a Magento Address collection containing address objects [...]

Magento Version: 1.6.rc1+ I just downloaded the release candidate for Magento 1.6, and I noticed a change that seemed like a regression, but a little digging made me realize it was something else. A lot of Magento developers (meaning me) like keeping their custom phtml files somewhere other than the the standard add/design/frontend file [...]

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 [...]

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 [...]

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 [...]

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 [...]

We 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?”