1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* @category Mygento |
6
|
|
|
* @package Mygento_Metrika |
7
|
|
|
* @copyright Copyright © 2015 NKS LLC. (http://www.mygento.ru) |
8
|
|
|
*/ |
9
|
|
|
class Mygento_Metrika_Model_Observer |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
public function addToCartComplete($observer) |
13
|
|
|
{ |
14
|
|
|
$product = $observer->getProduct(); |
15
|
|
|
$params = $observer->getRequest()->getParams(); |
16
|
|
|
|
17
|
|
|
$data = array( |
18
|
|
|
array( |
19
|
|
|
"ecommerce" => array( |
20
|
|
|
"add" => array( |
21
|
|
|
"products" => array( |
22
|
|
|
"id" => $product->getSku(), |
23
|
|
|
"name" => $product->getName(), |
24
|
|
|
"price" => $product->getPrice(), |
25
|
|
|
//"brand" => "Яндекс / Яndex", |
|
|
|
|
26
|
|
|
//"category" => "Аксессуары/Сумки", |
|
|
|
|
27
|
|
|
"quantity" => ($params['qty'] == 0 ? 1 : $params['qty']), |
28
|
|
|
) |
29
|
|
|
) |
30
|
|
|
) |
31
|
|
|
) |
32
|
|
|
); |
33
|
|
|
Mage::getSingleton('core/session')->setMetrika($data); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function removeFromCartComplete($observer) |
37
|
|
|
{ |
38
|
|
|
$product = $observer->getQuoteItem()->getProduct(); |
39
|
|
|
$data = array( |
40
|
|
|
array( |
41
|
|
|
"ecommerce" => array( |
42
|
|
|
"remove" => array( |
43
|
|
|
"products" => array( |
44
|
|
|
"id" => $product->getSku(), |
45
|
|
|
"name" => $product->getName(), |
46
|
|
|
) |
47
|
|
|
) |
48
|
|
|
) |
49
|
|
|
) |
50
|
|
|
); |
51
|
|
|
Mage::getSingleton('core/session')->setMetrika($data); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function removeDomainPolicyHeader($observer) |
55
|
|
|
{ |
56
|
|
|
/** @var Mage_Core_Controller->getCurrentAreaDomainPolicy_Varien_Action $action */ |
|
|
|
|
57
|
|
|
$action = $observer->getControllerAction(); |
58
|
|
|
|
59
|
|
|
if ('frontend' == $action->getLayout()->getArea()) { |
60
|
|
|
/** @var Mage_Core_Controller_Response_Http $response */ |
61
|
|
|
$response = $action->getResponse(); |
62
|
|
|
$url = parse_url(Mage::helper('core/http')->getHttpReferer()); |
63
|
|
|
if ($url['host'] == 'webvisor.com') { |
64
|
|
|
$response->clearHeader('X-Frame-Options'); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.