1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Attribute\Observers\AttributeOptionValueUpdateObserver |
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
|
|
|
* @author Vadim Justus <[email protected]> |
16
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
17
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
18
|
|
|
* @link https://github.com/techdivision/import-attribute |
19
|
|
|
* @link http://www.techdivision.com |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace TechDivision\Import\Attribute\Observers; |
23
|
|
|
|
24
|
|
|
use TechDivision\Import\Utils\StoreViewCodes; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Observer that update's the attribute option values found in the additional CSV file. |
28
|
|
|
* |
29
|
|
|
* @author Tim Wagner <[email protected]> |
30
|
|
|
* @author Vadim Justus <[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-attribute |
34
|
|
|
* @link http://www.techdivision.com |
35
|
|
|
*/ |
36
|
|
|
class AttributeOptionValueUpdateObserver extends AttributeOptionValueObserver |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Initialize the EAV attribute option value with the passed attributes and returns an instance. |
41
|
|
|
* |
42
|
|
|
* @param array $attr The EAV attribute option value attributes |
43
|
|
|
* |
44
|
|
|
* @return array The initialized EAV attribute option value |
45
|
|
|
*/ |
46
|
|
|
protected function initializeAttribute(array $attr) |
47
|
|
|
{ |
48
|
|
|
// initialize the data to load the EAV attribute option |
49
|
|
|
$optionId = $this->getLastOptionId(); |
50
|
|
|
$storeId = $this->getRowStoreId(StoreViewCodes::ADMIN); |
51
|
|
|
|
52
|
|
|
// try to load the EAV attribute option value |
53
|
|
|
if ($attributeOptionValue = $this->loadAttributeOptionValueByOptionIdAndStoreId($optionId, $storeId)) { |
54
|
|
|
return $this->mergeEntity($attributeOptionValue, $attr); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// simply return the attributes |
58
|
|
|
return $attr; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Load's and return's the EAV attribute option value with the passed option ID and store ID. |
63
|
|
|
* |
64
|
|
|
* @param string $optionId The option ID |
65
|
|
|
* @param integer $storeId The store ID of the attribute option to load |
66
|
|
|
* |
67
|
|
|
* @return array The EAV attribute option value |
68
|
|
|
*/ |
69
|
|
|
protected function loadAttributeOptionValueByOptionIdAndStoreId($optionId, $storeId) |
70
|
|
|
{ |
71
|
|
|
return $this->getAttributeBunchProcessor()->loadAttributeOptionValueByOptionIdAndStoreId($optionId, $storeId); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|