Completed
Push — master ( 3579df...802965 )
by Tim
17:41 queued 16:18
created

EeUrlKeyAndPathObserver::getPrimaryKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Category\Ee\Observers\EeUrlKeyAndPathObserver
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-category-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Category\Ee\Observers;
22
23
use TechDivision\Import\Category\Ee\Utils\MemberNames;
24
25
/**
26
 * Observer that extracts the URL key/path from the category path and
27
 * adds them as two new columns with the their values for Magento 2 EE.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2019 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import-category-ee
33
 * @link      http://www.techdivision.com
34
 */
35
class EeUrlKeyAndPathObserver extends \TechDivision\Import\Category\Observers\UrlKeyAndPathObserver
36
{
37
38
    /**
39
     * The trait providing category import functionality.
40
     *
41
     * @var \TechDivision\Import\Category\Ee\Observers\EeCategoryObserverTrait
42
     */
43
    use EeCategoryObserverTrait;
44
45
    /**
46
     * Temporarily persist's the IDs of the passed category.
47
     *
48
     * @param array $category The category to temporarily persist the IDs for
49
     *
50
     * @return void
51
     */
52
    protected function setIds(array $category)
53
    {
54
55
        // pass the category to the parent method
56
        parent::setIds($category);
57
58
        // temporarily persist the row ID
59
        $this->setLastRowId(isset($category[MemberNames::ROW_ID]) ? $category[MemberNames::ROW_ID] : null);
60
    }
61
62
    /**
63
     * Return's the PK to of the product.
64
     *
65
     * @return integer The PK to create the relation with
66
     */
67
    protected function getPrimaryKey()
68
    {
69
        return $this->getLastRowId();
70
    }
71
}
72