|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Assemblers\ProductAttributeAssembler |
|
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 2018 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 |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Assemblers; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Product\Utils\MemberNames; |
|
24
|
|
|
use TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface; |
|
25
|
|
|
use TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface; |
|
26
|
|
|
use TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface; |
|
27
|
|
|
use TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface; |
|
28
|
|
|
use TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Assembler implementation that provides functionality to assemble product attribute data. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Tim Wagner <[email protected]> |
|
34
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
|
35
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
36
|
|
|
* @link https://github.com/techdivision/import-product |
|
37
|
|
|
* @link http://www.techdivision.com |
|
38
|
|
|
*/ |
|
39
|
|
|
class ProductAttributeAssembler implements ProductAttributeAssemblerInterface |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* The product datetime repository instance. |
|
44
|
|
|
* |
|
45
|
|
|
* @var \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $productDatetimeRepository; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* The product decimal repository instance. |
|
51
|
|
|
* |
|
52
|
|
|
* @var \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $productDecimalRepository; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* The product integer repository instance. |
|
58
|
|
|
* |
|
59
|
|
|
* @var \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $productIntRepository; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* The product text repository instance. |
|
65
|
|
|
* |
|
66
|
|
|
* @var \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $productTextRepository; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* The product varchar repository instance. |
|
72
|
|
|
* |
|
73
|
|
|
* @var \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface |
|
74
|
|
|
*/ |
|
75
|
|
|
protected $productVarcharRepository; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Initializes the assembler with the necessary repositories. |
|
79
|
|
|
* |
|
80
|
|
|
* @param \TechDivision\Import\Product\Repositories\ProductDatetimeRepositoryInterface $productDatetimeRepository The product datetime repository instance |
|
81
|
|
|
* @param \TechDivision\Import\Product\Repositories\ProductDecimalRepositoryInterface $productDecimalRepository The product decimal repository instance |
|
82
|
|
|
* @param \TechDivision\Import\Product\Repositories\ProductIntRepositoryInterface $productIntRepository The product integer repository instance |
|
83
|
|
|
* @param \TechDivision\Import\Product\Repositories\ProductTextRepositoryInterface $productTextRepository The product text repository instance |
|
84
|
|
|
* @param \TechDivision\Import\Product\Repositories\ProductVarcharRepositoryInterface $productVarcharRepository The product varchar repository instance |
|
85
|
|
|
*/ |
|
86
|
|
|
public function __construct( |
|
87
|
|
|
ProductDatetimeRepositoryInterface $productDatetimeRepository, |
|
88
|
|
|
ProductDecimalRepositoryInterface $productDecimalRepository, |
|
89
|
|
|
ProductIntRepositoryInterface $productIntRepository, |
|
90
|
|
|
ProductTextRepositoryInterface $productTextRepository, |
|
91
|
|
|
ProductVarcharRepositoryInterface $productVarcharRepository |
|
92
|
|
|
) { |
|
93
|
|
|
$this->productDatetimeRepository = $productDatetimeRepository; |
|
94
|
|
|
$this->productDecimalRepository = $productDecimalRepository; |
|
95
|
|
|
$this->productIntRepository = $productIntRepository; |
|
96
|
|
|
$this->productTextRepository = $productTextRepository; |
|
97
|
|
|
$this->productVarcharRepository = $productVarcharRepository; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Intializes the existing attributes for the entity with the passed primary key. |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $pk The primary key of the entity to load the attributes for |
|
104
|
|
|
* @param integer $storeId The ID of the store view to load the attributes for |
|
105
|
|
|
* |
|
106
|
|
|
* @return array The entity attributes |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getProductAttributesByPrimaryKeyAndStoreId($pk, $storeId) |
|
109
|
|
|
{ |
|
110
|
|
|
|
|
111
|
|
|
// initialize the array for the attributes |
|
112
|
|
|
$attributes = array(); |
|
113
|
|
|
|
|
114
|
|
|
// load the datetime attributes |
|
115
|
|
|
foreach ($this->productDatetimeRepository->findAllByPrimaryKeyAndStoreId($pk, $storeId) as $attribute) { |
|
116
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
// load the decimal attributes |
|
120
|
|
|
foreach ($this->productDecimalRepository->findAllByPrimaryKeyAndStoreId($pk, $storeId) as $attribute) { |
|
121
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
// load the integer attributes |
|
125
|
|
|
foreach ($this->productIntRepository->findAllByPrimaryKeyAndStoreId($pk, $storeId) as $attribute) { |
|
126
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
// load the text attributes |
|
130
|
|
|
foreach ($this->productTextRepository->findAllByPrimaryKeyAndStoreId($pk, $storeId) as $attribute) { |
|
131
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
// load the varchar attributes |
|
135
|
|
|
foreach ($this->productVarcharRepository->findAllByPrimaryKeyAndStoreId($pk, $storeId) as $attribute) { |
|
136
|
|
|
$attributes[$attribute[MemberNames::ATTRIBUTE_ID]] = $attribute; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
// return the array with the attributes |
|
140
|
|
|
return $attributes; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|