Completed
Pull Request — 21.x (#36)
by Tim
15:40 queued 05:41
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 0
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
/**
24
 * Observer that extracts the URL key/path from the category path and
25
 * adds them as two new columns with the their values for Magento 2 EE.
26
 *
27
 * @author    Tim Wagner <[email protected]>
28
 * @copyright 2019 TechDivision GmbH <[email protected]>
29
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
30
 * @link      https://github.com/techdivision/import-category-ee
31
 * @link      http://www.techdivision.com
32
 */
33
class EeUrlKeyAndPathObserver extends \TechDivision\Import\Category\Observers\UrlKeyAndPathObserver
34
{
35
36
    /**
37
     * The trait providing category import functionality.
38
     *
39
     * @var \TechDivision\Import\Category\Ee\Observers\EeCategoryObserverTrait
40
     */
41
    use EeCategoryObserverTrait;
42
43
    /**
44
     * Temporarily persist's the IDs of the passed category.
45
     *
46
     * @param array $category The category to temporarily persist the IDs for
47
     *
48
     * @return void
49
     */
50
    protected function setIds(array $category)
51
    {
52
        $this->setLastRowId(isset($category[$this->getPkMemberName()]) ? $category[$this->getPkMemberName()] : null);
53
    }
54
55
    /**
56
     * Return's the PK to of the product.
57
     *
58
     * @return integer The PK to create the relation with
59
     */
60
    protected function getPrimaryKey()
61
    {
62
        return $this->getLastRowId();
63
    }
64
}
65