1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Msi\Utils\SqlStatements |
5
|
|
|
* |
6
|
|
|
* PHP version 7 |
7
|
|
|
* |
8
|
|
|
* @author Tim Wagner <[email protected]> |
9
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
10
|
|
|
* @license https://opensource.org/licenses/MIT |
11
|
|
|
* @link https://github.com/techdivision/import-product-msi |
12
|
|
|
* @link http://www.techdivision.com |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace TechDivision\Import\Product\Msi\Repositories; |
16
|
|
|
|
17
|
|
|
use TechDivision\Import\Product\Msi\Utils\SqlStatementKeys; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Repository class with the SQL statements to use. |
21
|
|
|
* |
22
|
|
|
* @author Tim Wagner <[email protected]> |
23
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
24
|
|
|
* @license https://opensource.org/licenses/MIT |
25
|
|
|
* @link https://github.com/techdivision/import-product-msi |
26
|
|
|
* @link http://www.techdivision.com |
27
|
|
|
*/ |
28
|
|
|
class SqlStatementRepository extends \TechDivision\Import\Product\Repositories\SqlStatementRepository |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The SQL statements. |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
private $statements = array( |
37
|
|
|
SqlStatementKeys::INVENTORY_SOURCE_ITEM => |
38
|
|
|
'SELECT * |
39
|
|
|
FROM ${table:inventory_source_item} |
40
|
|
|
WHERE source_item_id = :source_item_id', |
41
|
|
|
SqlStatementKeys::INVENTORY_SOURCES => |
42
|
|
|
'SELECT * |
43
|
|
|
FROM ${table:inventory_source}', |
44
|
|
|
SqlStatementKeys::INVENTORY_SOURCE_ITEMS => |
45
|
|
|
'SELECT * |
46
|
|
|
FROM ${table:inventory_source_item}', |
47
|
|
|
SqlStatementKeys::INVENTORY_SOURCE_ITEM_BY_SKU_AND_SOURCE_CODE => |
48
|
|
|
'SELECT * |
49
|
|
|
FROM ${table:inventory_source_item} |
50
|
|
|
WHERE sku = :sku |
51
|
|
|
AND source_code = :source_code', |
52
|
|
|
SqlStatementKeys::CREATE_INVENTORY_SOURCE_ITEM => |
53
|
|
|
'INSERT |
54
|
|
|
INTO ${table:inventory_source_item} |
55
|
|
|
(source_code, |
56
|
|
|
sku, |
57
|
|
|
quantity, |
58
|
|
|
status) |
59
|
|
|
VALUES (:source_code, |
60
|
|
|
:sku, |
61
|
|
|
:quantity, |
62
|
|
|
:status)', |
63
|
|
|
SqlStatementKeys::UPDATE_INVENTORY_SOURCE_ITEM => |
64
|
|
|
'UPDATE ${table:inventory_source_item} |
65
|
|
|
SET source_code = :source_code, |
66
|
|
|
sku = :sku, |
67
|
|
|
quantity = :quantity, |
68
|
|
|
status = :status |
69
|
|
|
WHERE source_item_id = :source_item_id', |
70
|
|
|
SqlStatementKeys::DELETE_INVENTORY_SOURCE_ITEM => |
71
|
|
|
'DELETE |
72
|
|
|
FROM ${table:inventory_source_item} |
73
|
|
|
WHERE source_item_id = :source_item_id', |
74
|
|
|
SqlStatementKeys::DELETE_INVENTORY_SOURCE_ITEM_BY_SKU_AND_SOURCE_CODE => |
75
|
|
|
'DELETE |
76
|
|
|
FROM ${table:inventory_source_item} |
77
|
|
|
WHERE sku = :sku |
78
|
|
|
AND source_code = :source_code' |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Initializes the SQL statement repository with the primary key and table prefix utility. |
83
|
|
|
* |
84
|
|
|
* @param \IteratorAggregate<\TechDivision\Import\Dbal\Utils\SqlCompilerInterface> $compilers The array with the compiler instances |
85
|
|
|
*/ |
86
|
|
|
public function __construct(\IteratorAggregate $compilers) |
87
|
|
|
{ |
88
|
|
|
|
89
|
|
|
// pass primary key + table prefix utility to parent instance |
90
|
|
|
parent::__construct($compilers); |
91
|
|
|
|
92
|
|
|
// compile the SQL statements |
93
|
|
|
$this->compile($this->statements); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|