I tend to listen to a decent number of podcasts. Usually while doing the dishes, running, or something or other in the park. Some are book/comic related and help me keep up to date with what’s coming out and how some books were that I didn’t have time to read. Others are tech and help me get other opinions on the new libraries or trends. I’ve found a number of fun libraries/how-tos from listening. Check them out below, what do you listen to?
Have you ever wanted to create a stateless request in Magento? Something that doesn’t touch any of Magento’s sessions? We were having issues with some of the ajax calls on our cart and checkout pages mucking with the user’s cart and had get stateless on these calls. The issue we were having was our checkout page was loading, then a javascript include was going out and bringing code from a 3rd party relevance engine into our dom, which was in turn calling back an ajax request to our servers. This issue with this being that at the start of the page load, the checkout session was being set to a certain state. This state was then being sent through the rest of the page load, and the ajax calls. Unfortunately, by the time the ajax call got back to our server, the session was different in both locations, creating a race condition. The ajax request usually won, removing the work the full page load had done with trying to process checkout. The good news was there was nothing in the ajax call that needed to touch the session, it was just some data lookup. So, nix the session part of that call, and our troubles should be over… Magento’s api controller is the only place that implements a stateless request this but its fairly easy to do (after a bit of digging).
As long as Mage_Core_Controller_Varien_Action is a parent in your controller’s hierchy, you are good to go (it probably is). This class has a const FLAG_NO_START_SESSION which looks promising. Digging into the code a little we see that it controls whether cookies are processed or the session is started:
Ever want to open all the Jira’s on the screen (search and filter views) in new tabs? Jess does, I do, and you should too!
For firefox and chrome we now have the JiraTabs bookmark button.
Drag this link up to your bookmarks bar: JiraTabs. Then, whenever you are on a filter or search view of Jira’s, click the button and all the jira’s on your screen will open up in new tabs
We’re ajaxing part of the Magento shopping cart so we need to modify/extend some of the cart controller functionality. Sometimes when modifying controller’s you have to worry about updating the routes. For this, we don’t need to, we still want all the urls to be used the same way.
As a result of temporal interference by Sarah Connor, her son John, Miles Dyson, and the T-800[2] destroyingCyberdyne headquarters and all backups of the research in 1995, the date for Judgment day is moved back to here.[3] Skynet is destined to go online a few days earlier on April 19, 2011 at 20:11
I started using Remember the Milk recently but didn’t want the gmail gadget to be so far down on the left hand side of my screen. There is no built in way to move gadgets to the right hand side with the exception of chat (labels used to do this but was removed in favor of drag in drop back in late 2009).
If you don’t have anything in the right hand column, enable Right-Side Chat from Gmail Labs. We are going to add in some custom css to gmail so install either Stylist for Chrome or Stylish for Firefox.
In chrome you can also restrict the domain to mail.google.com. For me, the Remember the Milk gadget was the 8th child. Play with this until it looks right for you. You may also have to play with the “top” element depending on how much room your chat gadget takes up
I’ve been loving my Kindle 3 since I upgraded from my sony reader. There are so many options for getting various reading materials onto it. Here are a few of the ones I like the best:
Want to get some RSS feeds onto the Kindle? (12 feeds for free) KindleFeeder is the way to go. It also has a bookmarklet for capturing and sending whole pages from your browser.
I use this to send articles in Google Reader that I want to read later to my Kindle. I use my starred items to do this. Starred items have their own RSS feed which you can put into kindlefeeder. For information on how to get the link to the RSS of your starred items, click here.
“Send to Kindle” for chrome is a button that will send the content of the page your are currently viewing.
The third method is the built in free Kindle email address that isn’t broadly advertised: your.name@free.kindle.com will beam most docs that you mail it to your Kindle over wifi (does not work with 3G)
Calibre is great for managing what is on your Kindle and converting just about any file format to .mobi (a format the Kindle can read)
I’ve also wrapped this into a module that you can drop right into your project. Details here
Example output:
.../app/code/community/Timbroder/Stack/Helper/Callstack.php line 16 calls get_callstack()
.../app/design/frontend/mongoose/default/template/catalog/cms/bikes_bmx.phtml line 12 calls toLog()
.../app/design/frontend/mongoose/default/template/catalog/cms/bikes.phtml line 21 calls require_once()
.../app/code/core/Mage/Core/Block/Template.php line 212 calls include()
.../app/code/core/Mage/Core/Block/Template.php line 239 calls fetchView()
.../app/code/core/Mage/Core/Block/Template.php line 253 calls renderView()
.../app/code/core/Mage/Core/Block/Abstract.php line 668 calls _toHtml()
.../app/code/core/Mage/Core/Model/Email/Template/Filter.php line 190 calls toHtml()
.../lib/Varien/Filter/Template.php line 134 calls call_user_func()
.../app/code/core/Mage/Core/Model/Email/Template/Filter.php line 501 calls filter()
.../app/code/core/Mage/Cms/Block/Page.php line 100 calls filter()
.../app/code/core/Mage/Core/Block/Abstract.php line 668 calls _toHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 513 calls toHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 460 calls _getChildHtml()
.../app/code/local/Mage/Page/Block/Html/Wrapper.php line 52 calls getChildHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 668 calls _toHtml()
.../app/code/core/Mage/Core/Block/Text/List.php line 43 calls toHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 668 calls _toHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 513 calls toHtml()
.../app/code/core/Mage/Core/Block/Abstract.php line 464 calls _getChildHtml()
.../app/design/frontend/mongoose/default/template/page/1column.phtml line 55 calls getChildHtml()
.../app/code/core/Mage/Core/Block/Template.php line 212 calls include()
.../app/code/core/Mage/Core/Block/Template.php line 239 calls fetchView()
.../app/code/core/Mage/Core/Block/Template.php line 253 calls renderView()
.../app/code/core/Mage/Core/Block/Abstract.php line 668 calls _toHtml()
.../app/code/core/Mage/Core/Model/Layout.php line 529 calls toHtml()
.../app/code/local/Mage/Core/Controller/Varien/Action.php line 389 calls getOutput()
.../app/code/core/Mage/Cms/Helper/Page.php line 130 calls renderLayout()
.../app/code/core/Mage/Cms/Helper/Page.php line 52 calls _renderPage()
.../app/code/core/Mage/Cms/controllers/PageController.php line 45 calls renderPage()
.../app/code/local/Mage/Core/Controller/Varien/Action.php line 418 calls viewAction()
.../app/code/core/Mage/Core/Controller/Varien/Router/Standard.php line 254 calls dispatch()
.../app/code/core/Mage/Core/Controller/Varien/Front.php line 177 calls match()
.../app/code/core/Mage/Core/Model/App.php line 304 calls dispatch()
.../app/Mage.php line 598 calls run()
.../index.php line 155 calls run()
Magento ships with widget functionality that lets you build out data models and then reuse them on product and CMS pages. If you want to use these in a custom template however, you are out of luck. This can be done by extending the Widget Collection class.
Create the following directory structure: app/code/local/Mage/Widget/Model/Myswql4/Widget/Instance
Copy app/code/core/Mage/Widget/Model/Myswql4/Widget/Instance/Collection.php into your new directory
The Mage_Widget_Model_Mysql4_Widget_Instance_Collection comes with a store filter but thats about it. To be more usefull we are going to add a type filter, a title filter, and a sorter.
class Mage_Widget_Model_Mysql4_Widget_Instance_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
/**
* Constructor
*/
protected function _construct()
{
parent::_construct();
$this->_init('widget/widget_instance');
}
/**
* Filter by store ids
*
* @param array|integer $storeIds
* @param boolean $withDefaultStore if TRUE also filter by store id '0'
* @return Mage_Widget_Model_Mysql4_Widget_Instance_Collection
*/
public function addStoreFilter($storeIds = array(), $withDefaultStore = true)
{
if (!is_array($storeIds)) {
$storeIds = array($storeIds);
}
if ($withDefaultStore && !in_array(0, $storeIds)) {
array_unshift($storeIds, 0);
}
$select = $this->getSelect();
foreach ($storeIds as $storeId) {
$select->orWhere('FIND_IN_SET(?, `store_ids`)', $storeId);
}
return $this;
}
public function addTypeFilter($type) {
$this->getSelect()->where('type=?', $type);
return $this;
}
public function addTitleFilter($type) {
$this->getSelect()->where('title=?', $type);
return $this;
}
public function addAttributeToSort($attribute, $dir='asc') {
$this->getSelect()->order("{$attribute} {$dir}");
return $this;
}
}
Now we should be able to query any widgets from any template in our system:
Magento is great, but it needs a good amount of hardware behind it. Developing locally can get slow and cumbersome unless your environment is tweaked properly. Here are a few tips for boosting Magento performance without impacting the rest of your development environment. Please keep in mind that the memory allocations work well for my machine (dual core, 4 gigs of ram).
Database
Install innoDB. Magento can use the in-memory buffer pool to cache table indexes and data.
Configure my.ini: innodb_buffer_pool_size = 64M
innodb_thread_concurrency = 4 (or 8 if you have dual core)
query_cache_size = 64M
query_cache_limit = 2M
apache
enable mod_expires in httpd.conf
php in php.ini enable: realpath_cache_size = 16k
realpath_cache_ttl = 120
Install the eAccelerator binaries for php. APC is a better solution but is less compatible with windows. If you need to compile these, click here for instructions. Then configure it: extension=eaccelerator.dll
eaccelerator.shm_size=64
eaccelerator.cache_dir=C:\PHP\tmp
eaccelerator.enable=1
eaccelerator.optimizer=1
eaccelerator.check_mtime=1
eaccelerator.shm_max=0
Install memcached.
add the following lines inside the config of epp/etc/local.xml <cache>
<backend>memcached</backend>
<memcached>
<servers>
<server>
<host><![CDATA[localhost]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
</server>
</servers>
<compression><![CDATA[0]]></compression>
<cache_dir><![CDATA[]]></cache_dir>
<hashed_directory_level><![CDATA[]]></hashed_directory_level>
<hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix><![CDATA[]]></file_name_prefix>
</memcached>
</cache>
Admin Backend
Keep the indexes up to date (System > index management)
AIAIO is the blog of Alexander Interactive, covering progressive concepts in strategy, technology, branding, design and the user experience. And pickles.