Magento IMP 7


Config FPC Placeholder Definition

This should go in cache.xml. See Boilerplate FPC No-Cache Container for a boilerplate container.
<config> <placeholders> <namespace_module> <block>namespace_module/something</block> <placeholder>NAMESPACE_MODULE_UNIQUE_STRING</placeholder> <container>Namespace_Module_Model_Pagecache_Container</container> <cache_lifetime>86400</cache_lifetime> <!-- never gets used --> </namespace_module> </placeholders> </config>

Boilerplate FPC No-Cache Container

This container, when combined with a Placeholder Definition will cause the referenced block to never be cached.
/** * Yourcompany.com * * PHP Version 5 * * @category Namespace * @package Namespace_Module * @author Your Name <your.name@yourcompany.com> * @copyright 2012 yourcompany.com * @license http://www.yourcompany.com/license.txt Your license * @link N/A */ /** * Cache container * * @category Namespace * @package Namespace_Module * @author Your Name <your.name@yourcompany.com> * @license http://www.yourcompany.com/license.txt Your license * @link N/A */ class Namespace_Module_Model_Pagecache_Container extends Enterprise_PageCache_Model_Container_Abstract { /** * Get container individual cache id * * Override to return false to cause the block to never get cached * * @return string */ protected function _getCacheId() { return false; } /** * Render block content * * @return string */ protected function _renderBlock() { $block = $this->_placeholder->getAttribute('block'); $block = new $block; // only needed if the block uses a template $block->setTemplate($this->_placeholder->getAttribute('template')); return $block->toHtml(); } /** * Generate placeholder content before application was initialized and * apply to page content if possible * * Override to enforce calling {@see _renderBlock()} * * @param string &$content The content * * @return bool */ public function applyWithoutApp(&$content) { return false; } }

Using Differing Setup Classes In One Module

On occasion you may have a module which requires both EAV and flat resource setup classes, in this situation you can instantiate a setup class as this note shows.
Eav:
$installer = Mage::getModel('eav/entity_setup', 'eav_setup');
Flat:
$installer = Mage::getResourceModel('core/setup', 'core_setup');
You can then continue with the setup script as you normally would.

Converting A Quote Attribute To An Order

<config> <global> <fieldsets> <sales_convert_quote> <some_attribute> <to_order>*</to_order> </some_attribute> </sales_convert_quote> </fieldsets> </global> </config>

Boilerplate Admin Controller

/** * Yourcompany.com * * PHP Version 5 * * @category Namespace * @package Namespace_Module * @author Your Name <your.name@yourcompany.com> * @copyright 2012 yourcompany.com * @license http://www.yourcompany.com/license.txt Your license * @link N/A */ /** * A description of the controller * * @category Namespace * @package Namespace_Module * @author Your Name <your.name@yourcompany.com> * @license http://www.yourcompany.com/license.txt Your license * @link N/A */ class Namespace_Module_Adminhtml_SomeController extends Mage_Adminhtml_Controller_Action { /** * Control access to this controller via ACL * * @return bool */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('the/acl/xpath'); } /** * Index action * * @return void */ public function indexAction() { $this->_title($this->__('Module'))->_title($this->__('Something')); $this->loadLayout(); $this->_setActiveMenu('namespace_module/something'); $this->_addBreadcrumb(Mage::helper('namespace_module')->__('Module'), Mage::helper('namespace_module')->__('Something')); $this->renderLayout(); } }

Enabling The Profiler

In index.php uncomment this line:
#Varien_Profiler::enable();
In the admin enable the profiler output:
Set System > ConfigurationAdvanced > Developer >Debug > Profiler to yes
To enable the Zend_Db profiler add the following node to your app/etc/local.xml file. It can be added into your database connection configuration. The output will also be displayed if the admin setting above is set to true.
<global> <resources> <default_setup> <connection> <profiler>true</profiler> </connection> </default_setup> </resources> </global>

Enabling MySQL Query Logging

In /lib/Varien/Db/Adapter/Pdo/Mysql.php change this property to true:
/** * Write SQL debug data to file * * @var bool */ protected $_debug = false;
To enable logging for queries slower than a certain time, alter this property:
/** * Minimum query duration time to be logged * * @var float */ protected $_logQueryTime = 0.05;
To log all queries, set this property to true:
/** * Log all queries (ignored minimum query duration time) * * @var bool */ protected $_logAllQueries = false;
Optionally, you can log the call stack, to do so change this property to true:
/** * Add to log call stack data (backtrace) * * @var bool */ protected $_logCallStack = false;
To change to location of the log file, alter this property:
/** * Path to SQL debug data log * * @var string */ protected $_debugFile = 'var/debug/pdo_mysql.log';

No comments:

Post a Comment