Skip to content

Instantly share code, notes, and snippets.

View RabeaWahab's full-sized avatar
🎯

Rabea Abdelwahab RabeaWahab

🎯
View GitHub Profile
@RabeaWahab
RabeaWahab / Observer.php
Last active August 29, 2015 14:12
Observer
<?php
class Packagename_Modulename_Model_Observer
{
public function enableCmsBlockCaching($observer)
{
$block = $observer->getBlock();
if ($block instanceof Mage_Cms_Block_Widget_Block
|| $block instanceof Mage_Cms_Block_Block
) {
$cacheKeyData = array(
<?xml version="1.0" encoding="UTF-8"?>
<config>
<placeholders>
<cmsblock_tag>
<block>cms/block</block>
<placeholder>HTML_CMS_CACHED_ID</placeholder>
<container>Packagename_Modulename_Model_Punchhole</container>
<cache_lifetime>86400</cache_lifetime>
</cmsblock_tag>
<widget_tag>
<?php
class Packagename_Modulename_Block_Block extends Mage_Cms_Block_Block
{
public function getCacheKeyInfo() {
return array('block_id' => $this->getBlockId());
}
}
?>
<?php
<?php
class Packagename_Modulename_Model_Punchhole extends Enterprise_PageCache_Model_Container_Abstract
{
protected function _getIdentifier()
{
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
}
/**
* Get cache identifier
<?php
class Packagename_Modulename_Model_Punchhole2 extends Enterprise_PageCache_Model_Container_Abstract
{
protected function _getIdentifier()
{
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
}
/**
* Get cache identifier
<core_block_abstract_to_html_before>
<observers>
<cms_checker>
<type>Singleton</type>
<method>enableCmsBlockCaching</method>
<class>Packagename_Modulename_Model_Observer</class>
</cms_checker>
</observers>
</core_block_abstract_to_html_before>
<field name="film_title" type="text_general" indexed="true" stored="true" />
<field name="film_description" type="text_general" indexed="true" stored="true" />
<field name="film_category" type="text_general" indexed="true" stored="true" />
<field name="film_length" type="text_general" indexed="true" stored="true" />
<field name="film_rating" type="text_general" indexed="true" stored="true" />
<field name="film_actors" type="text_general" indexed="true" stored="true" />
<uniqueKey>id</uniqueKey>
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
<str name="defType">edismax</str>
<str name="fl">*</str>
<?php
use UnitedPrototype\GoogleAnalytics;
// initiate the tracker
$tracker = new GoogleAnalytics\Tracker($accountId, $account_domain);
// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);