1
1
<?php
2
2
3
3
class Creare_CreareSeoCore_Model_Observer extends Mage_Core_Model_Abstract {
4
+
4
5
/* Our function to change the META robots tag on Parameter based category pages */
5
6
6
7
public function changeRobots ($ observer ) {
@@ -171,6 +172,8 @@ public function saveConfigOnConfigLoad($observer) {
171
172
}
172
173
}
173
174
}*/
175
+
176
+ /* Checks if the page loaded is the canonical version, if not redirects to that version */
174
177
175
178
public function forceProductCanonical (Varien_Event_Observer $ observer )
176
179
{
@@ -188,24 +191,24 @@ public function forceProductCanonical(Varien_Event_Observer $observer)
188
191
}
189
192
}
190
193
}
194
+
195
+ /* Adds the page title and meta description to the contact page's <head> */
191
196
192
197
public function contactsMetaData (Varien_Event_Observer $ observer )
193
198
{
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 ' )) {
198
201
$ observer ->getEvent ()->getLayout ()->getBlock ('head ' )->setTitle (Mage::helper ('creareseocore/meta ' )->config ('contacts_title ' ));
199
202
}
200
-
201
- if (Mage::helper ('creareseocore/meta ' )->config ('contacts_metadesc ' ))
202
- {
203
+
204
+ if (Mage::helper ('creareseocore/meta ' )->config ('contacts_metadesc ' )) {
203
205
$ observer ->getEvent ()->getLayout ()->getBlock ('head ' )->setDescription (Mage::helper ('creareseocore/meta ' )->config ('contacts_metadesc ' ));
204
206
}
205
207
}
206
-
207
208
}
208
-
209
+
210
+ /* If set, replaces the homepage title with the definitive one set in the config */
211
+
209
212
public function forceHomepageTitle ($ observer )
210
213
{
211
214
if (Mage::getStoreConfig ('creareseocore/defaultseo/forcehptitle ' )) {
@@ -222,6 +225,8 @@ public function forceHomepageTitle($observer)
222
225
}
223
226
}
224
227
}
228
+
229
+ /* On relevant pages, will override the page title with the fallback if one isn't set in the editor */
225
230
226
231
public function setTitle ($ observer )
227
232
{
@@ -239,6 +244,8 @@ public function setTitle($observer)
239
244
240
245
$ layout ->generateXml ();
241
246
}
247
+
248
+ /* On relevant pages, will override the meta desc with the fallback if one isn't set in the editor */
242
249
243
250
public function setDescription ($ observer )
244
251
{
@@ -346,9 +353,13 @@ public function setMandatoryAltTag($observer)
346
353
}
347
354
}
348
355
356
+ /* Sets Google Analytics to use UA when the version is less that 1.9.1 and it is set in the config */
357
+
349
358
public function setUA ($ observer )
350
359
{
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 ' , '< ' ))
352
363
{
353
364
$ layout = $ observer ->getEvent ()->getLayout ();
354
365
$ 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