While integrating Solr with Magento I decided to create a superclass for the facet blocks to extend since the majority of their functionality was rather similar. I started by creating a file named Facet.php with the class Company_Search_Block_Facet in app/local/Company/Search/Block that extended the Magento_Core_Block_Template class. I next created the subfolder app/local/Company/Search/Block/Facet to store all my facet blocks and a file named Size.php that extended Company_Search_Block_Facet. The tricky part was getting it to work properly. I attempting to add a facet blocks to the right column using the following code.
$this->getLayout()->createBlock(’search/facet/size’);
The problem was it loaded my superclass Company_Search_Block_Facet instead of my child class Company_Search_Block_Facet_Size. After digging through some of Magento’s source code I found the solution. You need to use an underscore instead of a forward slash to load blocks in subfolders.
$this->getLayout()->createBlock(’search/facet_size’);
Now I can easily store my blocks in a subfolder keeping my Block folder nice and tidy.