Completed
Push — 1.0 ( f36b6b...3f4232 )
by Nikita
04:07
created

removeDomainPolicyHeader()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 8
nc 3
nop 1
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",
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
26
                            //"category" => "Аксессуары/Сумки",
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
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 */
1 ignored issue
show
Documentation introduced by
The doc-type Mage_Core_Controller->ge...ainPolicy_Varien_Action could not be parsed: Unknown type name "Mage_Core_Controller-" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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