1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Media\Subjects\MediaSubject |
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 |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Media\Subjects; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* A trait implementation that provides functionality to handle the media import on subject level. |
25
|
|
|
* |
26
|
|
|
* @author Tim Wagner <[email protected]> |
27
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
28
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
29
|
|
|
* @link https://github.com/techdivision/import-product-media |
30
|
|
|
* @link http://www.techdivision.com |
31
|
|
|
*/ |
32
|
|
|
trait MediaSubjectTrait |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The ID of the parent product to relate the variant with. |
37
|
|
|
* |
38
|
|
|
* @var integer |
39
|
|
|
*/ |
40
|
|
|
protected $parentId; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The value ID of the created media gallery entry. |
44
|
|
|
* |
45
|
|
|
* @var integer |
46
|
|
|
*/ |
47
|
|
|
protected $parentValueId; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The Magento installation directory. |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $installationDir; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* The position counter, if no position for the product media gallery value has been specified. |
58
|
|
|
* |
59
|
|
|
* @var integer |
60
|
|
|
*/ |
61
|
|
|
protected $positionCounter = 1; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Set's the ID of the parent product to relate the variant with. |
65
|
|
|
* |
66
|
|
|
* @param integer $parentId The ID of the parent product |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function setParentId($parentId) |
71
|
|
|
{ |
72
|
|
|
$this->parentId = $parentId; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Return's the ID of the parent product to relate the variant with. |
77
|
|
|
* |
78
|
|
|
* @return integer The ID of the parent product |
79
|
|
|
*/ |
80
|
|
|
public function getParentId() |
81
|
|
|
{ |
82
|
|
|
return $this->parentId; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Set's the value ID of the created media gallery entry. |
87
|
|
|
* |
88
|
|
|
* @param integer $parentValueId The ID of the created media gallery entry |
89
|
|
|
* |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
|
|
public function setParentValueId($parentValueId) |
93
|
|
|
{ |
94
|
|
|
$this->parentValueId = $parentValueId; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Return's the value ID of the created media gallery entry. |
99
|
|
|
* |
100
|
|
|
* @return integer The ID of the created media gallery entry |
101
|
|
|
*/ |
102
|
|
|
public function getParentValueId() |
103
|
|
|
{ |
104
|
|
|
return $this->parentValueId; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Reset the position counter to 1. |
109
|
|
|
* |
110
|
|
|
* @return void |
111
|
|
|
*/ |
112
|
|
|
public function resetPositionCounter() |
113
|
|
|
{ |
114
|
|
|
$this->positionCounter = 0; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Returns the acutal value of the position counter and raise's it by one. |
119
|
|
|
* |
120
|
|
|
* @return integer The actual value of the position counter |
121
|
|
|
*/ |
122
|
|
|
public function raisePositionCounter() |
123
|
|
|
{ |
124
|
|
|
return $this->positionCounter++; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|