1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Ee\Observers\EeProductAttributeUpdateObserver |
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 2016 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-product-ee |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Ee\Observers; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Product\Ee\Utils\MemberNames; |
24
|
|
|
use TechDivision\Import\Ee\Observers\EeAttributeObserverTrait; |
25
|
|
|
use TechDivision\Import\Product\Observers\ProductAttributeUpdateObserver; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Observer that provides product attribute update functionality. |
29
|
|
|
* |
30
|
|
|
* @author Tim Wagner <[email protected]> |
31
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
32
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
33
|
|
|
* @link https://github.com/techdivision/import-product-ee |
34
|
|
|
* @link http://www.techdivision.com |
35
|
|
|
*/ |
36
|
|
|
class EeProductAttributeUpdateObserver extends ProductAttributeUpdateObserver |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The trait providing basic EE product attribute functionality. |
41
|
|
|
* |
42
|
|
|
* @var \TechDivision\Import\Ee\Observers\EeAttributeObserverTrait |
43
|
|
|
*/ |
44
|
|
|
use EeAttributeObserverTrait; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Initialize the category product with the passed attributes and returns an instance. |
48
|
|
|
* |
49
|
|
|
* @param array $attr The category product attributes |
50
|
|
|
* |
51
|
|
|
* @return array The initialized category product |
52
|
|
|
*/ |
53
|
|
|
protected function initializeAttribute(array $attr) |
54
|
|
|
{ |
55
|
|
|
|
56
|
|
|
// load the supported backend types |
57
|
|
|
$backendTypes = $this->getBackendTypes(); |
58
|
|
|
|
59
|
|
|
// initialize the persist method for the found backend type |
60
|
|
|
list (, $loadMethod) = $backendTypes[$this->backendType]; |
61
|
|
|
|
62
|
|
|
// load row/store/attribute ID |
63
|
|
|
$rowId = $attr[MemberNames::ROW_ID]; |
64
|
|
|
$storeId = $attr[MemberNames::STORE_ID]; |
65
|
|
|
$attributeId = $attr[MemberNames::ATTRIBUTE_ID]; |
66
|
|
|
|
67
|
|
|
// try to load the attribute with the passed row/attribute/store ID |
68
|
|
|
// and merge it with the attributes |
69
|
|
|
if ($entity = $this->$loadMethod($rowId, $attributeId, $storeId)) { |
70
|
|
|
return $this->mergeEntity($entity, $attr); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
// otherwise simply return the attributes |
74
|
|
|
return $attr; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Load's and return's the datetime attribute with the passed row/attribute/store ID. |
79
|
|
|
* |
80
|
|
|
* @param integer $pk The row ID of the attribute |
81
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
82
|
|
|
* @param integer $storeId The store ID of the attribute |
83
|
|
|
* |
84
|
|
|
* @return array|null The datetime attribute |
85
|
|
|
*/ |
86
|
|
|
protected function loadDatetimeAttribute($pk, $attributeId, $storeId) |
87
|
|
|
{ |
88
|
|
|
return $this->getProductBunchProcessor()->loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId($pk, $attributeId, $storeId); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Load's and return's the decimal attribute with the passed row/attribute/store ID. |
93
|
|
|
* |
94
|
|
|
* @param integer $pk The row ID of the attribute |
95
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
96
|
|
|
* @param integer $storeId The store ID of the attribute |
97
|
|
|
* |
98
|
|
|
* @return array|null The decimal attribute |
99
|
|
|
*/ |
100
|
|
|
protected function loadDecimalAttribute($pk, $attributeId, $storeId) |
101
|
|
|
{ |
102
|
|
|
return $this->getProductBunchProcessor()->loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId($pk, $attributeId, $storeId); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Load's and return's the integer attribute with the passed row/attribute/store ID. |
107
|
|
|
* |
108
|
|
|
* @param integer $pk The row ID of the attribute |
109
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
110
|
|
|
* @param integer $storeId The store ID of the attribute |
111
|
|
|
* |
112
|
|
|
* @return array|null The integer attribute |
113
|
|
|
*/ |
114
|
|
|
protected function loadIntAttribute($pk, $attributeId, $storeId) |
115
|
|
|
{ |
116
|
|
|
return $this->getProductBunchProcessor()->loadProductIntAttributeByRowIdAndAttributeIdAndStoreId($pk, $attributeId, $storeId); |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Load's and return's the text attribute with the passed row/attribute/store ID. |
121
|
|
|
* |
122
|
|
|
* @param integer $pk The row ID of the attribute |
123
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
124
|
|
|
* @param integer $storeId The store ID of the attribute |
125
|
|
|
* |
126
|
|
|
* @return array|null The text attribute |
127
|
|
|
*/ |
128
|
|
|
protected function loadTextAttribute($pk, $attributeId, $storeId) |
129
|
|
|
{ |
130
|
|
|
return $this->getProductBunchProcessor()->loadProductTextAttributeByRowIdAndAttributeIdAndStoreId($pk, $attributeId, $storeId); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Load's and return's the varchar attribute with the passed row/attribute/store ID. |
135
|
|
|
* |
136
|
|
|
* @param integer $pk The row ID of the attribute |
137
|
|
|
* @param integer $attributeId The attribute ID of the attribute |
138
|
|
|
* @param integer $storeId The store ID of the attribute |
139
|
|
|
* |
140
|
|
|
* @return array|null The varchar attribute |
141
|
|
|
*/ |
142
|
|
|
protected function loadVarcharAttribute($pk, $attributeId, $storeId) |
143
|
|
|
{ |
144
|
|
|
return $this->getProductBunchProcessor()->loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId($pk, $attributeId, $storeId); |
|
|
|
|
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.