|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Attribute\Set\Repositories\SqlStatementKeys |
|
5
|
|
|
* |
|
6
|
|
|
* PHP version 7 |
|
7
|
|
|
* |
|
8
|
|
|
* @author Tim Wagner <[email protected]> |
|
9
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
10
|
|
|
* @license https://opensource.org/licenses/MIT |
|
11
|
|
|
* @link https://github.com/techdivision/import-attribute-set |
|
12
|
|
|
* @link http://www.techdivision.com |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace TechDivision\Import\Attribute\Set\Repositories; |
|
16
|
|
|
|
|
17
|
|
|
use TechDivision\Import\Attribute\Set\Utils\SqlStatementKeys; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Repository class with the SQL statements to use. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Tim Wagner <[email protected]> |
|
23
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
24
|
|
|
* @license https://opensource.org/licenses/MIT |
|
25
|
|
|
* @link https://github.com/techdivision/import-attribute-set |
|
26
|
|
|
* @link http://www.techdivision.com |
|
27
|
|
|
*/ |
|
28
|
|
|
class SqlStatementRepository extends \TechDivision\Import\Attribute\Repositories\SqlStatementRepository |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* The SQL statements. |
|
33
|
|
|
* |
|
34
|
|
|
* @var array |
|
35
|
|
|
*/ |
|
36
|
|
|
private $statements = array( |
|
37
|
|
|
SqlStatementKeys::CREATE_ATTRIBUTE_SET => |
|
38
|
|
|
'INSERT ${table:eav_attribute_set} |
|
39
|
|
|
(${column-names:eav_attribute_set}) |
|
40
|
|
|
VALUES (${column-placeholders:eav_attribute_set})', |
|
41
|
|
|
SqlStatementKeys::CREATE_ATTRIBUTE_GROUP => |
|
42
|
|
|
'INSERT ${table:eav_attribute_group} |
|
43
|
|
|
(${column-names:eav_attribute_group}) |
|
44
|
|
|
VALUES (${column-placeholders:eav_attribute_group})', |
|
45
|
|
|
SqlStatementKeys::UPDATE_ATTRIBUTE_SET => |
|
46
|
|
|
'UPDATE ${table:eav_attribute_set} |
|
47
|
|
|
SET ${column-values:eav_attribute_set} |
|
48
|
|
|
WHERE attribute_set_id = :attribute_set_id', |
|
49
|
|
|
SqlStatementKeys::UPDATE_ATTRIBUTE_GROUP => |
|
50
|
|
|
'UPDATE ${table:eav_attribute_group} |
|
51
|
|
|
SET ${column-values:eav_attribute_group} |
|
52
|
|
|
WHERE attribute_group_id = :attribute_group_id', |
|
53
|
|
|
SqlStatementKeys::DELETE_ATTRIBUTE_SET => |
|
54
|
|
|
'DELETE FROM ${table:eav_attribute_set} WHERE attribute_set_id = :attribute_set_id', |
|
55
|
|
|
SqlStatementKeys::DELETE_ATTRIBUTE_GROUP => |
|
56
|
|
|
'DELETE FROM ${table:eav_attribute_group} WHERE attribute_group_id = :attribute_group_id', |
|
57
|
|
|
SqlStatementKeys::ENTITY_ATTRIBUTES_BY_ATTRIBUTE_GROUP_ID => |
|
58
|
|
|
'SELECT * |
|
59
|
|
|
FROM ${table:eav_entity_attribute} |
|
60
|
|
|
WHERE attribute_group_id = :attribute_group_id', |
|
61
|
|
|
SqlStatementKeys::ENTITY_ATTRIBUTES_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_SET_NAME => |
|
62
|
|
|
'SELECT t0.* |
|
63
|
|
|
FROM ${table:eav_entity_attribute} t0 |
|
64
|
|
|
INNER JOIN ${table:eav_attribute_set} t1 |
|
65
|
|
|
ON t1.attribute_set_name = :attribute_set_name |
|
66
|
|
|
AND t1.entity_type_id = :entity_type_id |
|
67
|
|
|
AND t0.attribute_set_id = t1.attribute_set_id', |
|
68
|
|
|
SqlStatementKeys::EAV_ATTRIBUTE_GROUP_BY_ATTRIBUTE_SET_ID_AND_ATTRIBUTE_GROUP_CODE => |
|
69
|
|
|
'SELECT * |
|
70
|
|
|
FROM ${table:eav_attribute_group} |
|
71
|
|
|
WHERE attribute_set_id = :attribute_set_id |
|
72
|
|
|
AND attribute_group_code = :attribute_group_code' |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Initializes the SQL statement repository with the primary key and table prefix utility. |
|
77
|
|
|
* |
|
78
|
|
|
* @param \IteratorAggregate<\TechDivision\Import\Dbal\Utils\SqlCompilerInterface> $compilers The array with the compiler instances |
|
79
|
|
|
*/ |
|
80
|
|
|
public function __construct(\IteratorAggregate $compilers) |
|
81
|
|
|
{ |
|
82
|
|
|
|
|
83
|
|
|
// pass primary key + table prefix utility to parent instance |
|
84
|
|
|
parent::__construct($compilers); |
|
85
|
|
|
|
|
86
|
|
|
// compile the SQL statements |
|
87
|
|
|
$this->compile($this->statements); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|