|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Media\Ee\Observers\EeMediaGalleryValueUpdateObserver |
|
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-media-ee |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Media\Ee\Observers; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Product\Media\Ee\Utils\MemberNames; |
|
24
|
|
|
use TechDivision\Import\Product\Media\Observers\MediaGalleryValueUpdateObserver; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Observer that provides extended mapping functionality to map a SKU to a row ID (EE Feature). |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2016 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-product-media-ee |
|
33
|
|
|
* @link http://www.techdivision.com |
|
34
|
|
|
*/ |
|
35
|
|
|
class EeMediaGalleryValueUpdateObserver extends EeMediaGalleryValueObserver |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Initialize the product media gallery value with the passed attributes and returns an instance. |
|
40
|
|
|
* |
|
41
|
|
|
* @param array $attr The product media gallery value attributes |
|
42
|
|
|
* |
|
43
|
|
|
* @return array The initialized product media gallery value |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function initializeProductMediaGalleryValue(array $attr) |
|
46
|
|
|
{ |
|
47
|
|
|
|
|
48
|
|
|
// load the row/value/store ID |
|
49
|
|
|
$rowId = $attr[MemberNames::ROW_ID]; |
|
50
|
|
|
$valueId = $attr[MemberNames::VALUE_ID]; |
|
51
|
|
|
$storeId = $attr[MemberNames::STORE_ID]; |
|
52
|
|
|
|
|
53
|
|
|
// query whether the product media gallery value already exists or not |
|
54
|
|
|
if ($entity = $this->loadProductMediaGalleryValueByValueIdAndStoreIdAndRowId($valueId, $storeId, $rowId)) { |
|
55
|
|
|
return $this->mergeEntity($entity, $attr); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// simply return the attributes |
|
59
|
|
|
return $attr; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Load's the product media gallery value with the passed value/store/row ID. |
|
64
|
|
|
* |
|
65
|
|
|
* @param integer $valueId The value ID of the product media gallery value to load |
|
66
|
|
|
* @param string $storeId The store ID of the product media gallery value to load |
|
67
|
|
|
* @param string $rowId The row ID of the parent product of the product media gallery value to load |
|
68
|
|
|
* |
|
69
|
|
|
* @return array The product media gallery value |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function loadProductMediaGalleryValueByValueIdAndStoreIdAndRowId($valueId, $storeId, $rowId) |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->getSubject()->loadProductMediaGalleryValueByValueIdAndStoreIdAndRowId($valueId, $storeId, $rowId); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|