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
|
|
|
|