Skip to content

Commit bfaacaf

Browse files
committed
Made Universal Analytics only applicable when the version is less than 1.9.1 as it is supported in newer versions.
1 parent 0bf20b3 commit bfaacaf

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ app/etc/config.xml
3636
app/etc/local.xml
3737
app/etc/local.xml.additional
3838
app/etc/local.xml.template
39-
app/locale/en_US/
39+
app/locale/
4040
app/Mage.php
4141
cron.php
4242
cron.sh

app/code/community/Creare/CreareSeoCore/Model/Observer.php

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
class Creare_CreareSeoCore_Model_Observer extends Mage_Core_Model_Abstract {
4+
45
/* Our function to change the META robots tag on Parameter based category pages */
56

67
public function changeRobots($observer) {
@@ -171,6 +172,8 @@ public function saveConfigOnConfigLoad($observer) {
171172
}
172173
}
173174
}*/
175+
176+
/* Checks if the page loaded is the canonical version, if not redirects to that version */
174177

175178
public function forceProductCanonical(Varien_Event_Observer $observer)
176179
{
@@ -188,24 +191,24 @@ public function forceProductCanonical(Varien_Event_Observer $observer)
188191
}
189192
}
190193
}
194+
195+
/* Adds the page title and meta description to the contact page's <head> */
191196

192197
public function contactsMetaData(Varien_Event_Observer $observer)
193198
{
194-
if ($observer->getEvent()->getAction()->getRequest()->getRouteName() === "contacts")
195-
{
196-
if (Mage::helper('creareseocore/meta')->config('contacts_title'))
197-
{
199+
if ($observer->getEvent()->getAction()->getRequest()->getRouteName() === "contacts") {
200+
if (Mage::helper('creareseocore/meta')->config('contacts_title')) {
198201
$observer->getEvent()->getLayout()->getBlock('head')->setTitle(Mage::helper('creareseocore/meta')->config('contacts_title'));
199202
}
200-
201-
if (Mage::helper('creareseocore/meta')->config('contacts_metadesc'))
202-
{
203+
204+
if (Mage::helper('creareseocore/meta')->config('contacts_metadesc')) {
203205
$observer->getEvent()->getLayout()->getBlock('head')->setDescription(Mage::helper('creareseocore/meta')->config('contacts_metadesc'));
204206
}
205207
}
206-
207208
}
208-
209+
210+
/* If set, replaces the homepage title with the definitive one set in the config */
211+
209212
public function forceHomepageTitle($observer)
210213
{
211214
if (Mage::getStoreConfig('creareseocore/defaultseo/forcehptitle')) {
@@ -222,6 +225,8 @@ public function forceHomepageTitle($observer)
222225
}
223226
}
224227
}
228+
229+
/* On relevant pages, will override the page title with the fallback if one isn't set in the editor */
225230

226231
public function setTitle($observer)
227232
{
@@ -239,6 +244,8 @@ public function setTitle($observer)
239244

240245
$layout->generateXml();
241246
}
247+
248+
/* On relevant pages, will override the meta desc with the fallback if one isn't set in the editor */
242249

243250
public function setDescription($observer)
244251
{
@@ -346,9 +353,13 @@ public function setMandatoryAltTag($observer)
346353
}
347354
}
348355

356+
/* Sets Google Analytics to use UA when the version is less that 1.9.1 and it is set in the config */
357+
349358
public function setUA($observer)
350359
{
351-
if (Mage::getStoreConfig('creareseocore/googleanalytics/type'))
360+
$magentoVersion = Mage::getVersion();
361+
362+
if (Mage::getStoreConfig('creareseocore/googleanalytics/type') && version_compare($magentoVersion, '1.9.1', '<'))
352363
{
353364
$layout = $observer->getEvent()->getLayout();
354365
$layout->getUpdate()->addUpdate('<reference name="after_body_start"><remove name="google_analytics" /><block type="creareseocore/googleanalytics_ua" name="universal_analytics" template="creareseo/googleanalytics/ua.phtml" /></reference>');

0 commit comments

Comments
 (0)