|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\TierPrice\Repositories\SqlStatementRepository |
|
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 Klaas-Tido Rühl <[email protected]> |
|
15
|
|
|
* @author Tim Wagner <[email protected]> |
|
16
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
|
17
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
18
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
|
19
|
|
|
* @link https://www.techdivision.com |
|
20
|
|
|
* @link https://www.refusion.com |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace TechDivision\Import\Product\TierPrice\Repositories; |
|
24
|
|
|
|
|
25
|
|
|
use TechDivision\Import\Product\TierPrice\Utils\SqlStatementKeys; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Adds statements specifically required for tier price CRUD operations. |
|
29
|
|
|
* |
|
30
|
|
|
* @author Klaas-Tido Rühl <[email protected]> |
|
31
|
|
|
* @author Tim Wagner <[email protected]> |
|
32
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
|
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
34
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
|
35
|
|
|
* @link https://www.techdivision.com |
|
36
|
|
|
* @link https://www.refusion.com |
|
37
|
|
|
*/ |
|
38
|
|
|
class SqlStatementRepository extends \TechDivision\Import\Repositories\SqlStatementRepository |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* The SQL statements. |
|
43
|
|
|
* |
|
44
|
|
|
* @var array |
|
45
|
|
|
*/ |
|
46
|
|
|
private $statements = array( |
|
47
|
|
|
SqlStatementKeys::TIER_PRICES => |
|
48
|
|
|
'SELECT * |
|
49
|
|
|
FROM ${table:catalog_product_entity_tier_price}', |
|
50
|
|
|
SqlStatementKeys::TIER_PRICE_BY_PK_AND_ALL_GROUPS_AND_CUSTOMER_GROUP_ID_AND_QTY_AND_WEBSITE_ID => |
|
51
|
|
|
'SELECT * |
|
52
|
|
|
FROM ${table:catalog_product_entity_tier_price} |
|
53
|
|
|
WHERE ${pk:entity_id} = :${pk:entity_id} |
|
54
|
|
|
AND all_groups = :all_groups |
|
55
|
|
|
AND customer_group_id = :customer_group_id |
|
56
|
|
|
AND qty = :qty |
|
57
|
|
|
AND website_id = :website_id', |
|
58
|
|
|
SqlStatementKeys::DELETE_TIER_PRICE => |
|
59
|
|
|
'DELETE |
|
60
|
|
|
FROM ${table:catalog_product_entity_tier_price} |
|
61
|
|
|
WHERE value_id = :value_id', |
|
62
|
|
|
SqlStatementKeys::CREATE_TIER_PRICE => |
|
63
|
|
|
'INSERT |
|
64
|
|
|
INTO ${table:catalog_product_entity_tier_price} |
|
65
|
|
|
(all_groups, |
|
66
|
|
|
customer_group_id, |
|
67
|
|
|
qty, |
|
68
|
|
|
value, |
|
69
|
|
|
website_id, |
|
70
|
|
|
percentage_value, |
|
71
|
|
|
${pk:entity_id}) |
|
72
|
|
|
VALUES (:all_groups, |
|
73
|
|
|
:customer_group_id, |
|
74
|
|
|
:qty, |
|
75
|
|
|
:value, |
|
76
|
|
|
:website_id, |
|
77
|
|
|
:percentage_value, |
|
78
|
|
|
:${pk:entity_id})', |
|
79
|
|
|
SqlStatementKeys::UPDATE_TIER_PRICE => |
|
80
|
|
|
'UPDATE ${table:catalog_product_entity_tier_price} |
|
81
|
|
|
SET all_groups = :all_groups, |
|
82
|
|
|
customer_group_id = :customer_group_id, |
|
83
|
|
|
qty = :qty, |
|
84
|
|
|
value = :value, |
|
85
|
|
|
website_id = :website_id, |
|
86
|
|
|
percentage_value = :percentage_value, |
|
87
|
|
|
${pk:entity_id} = :${pk:entity_id} |
|
88
|
|
|
WHERE value_id = :value_id' |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Initializes the SQL statement repository with the primary key and table prefix utility. |
|
93
|
|
|
* |
|
94
|
|
|
* @param \IteratorAggregate<\TechDivision\Import\Utils\SqlCompilerInterface> $compilers The array with the compiler instances |
|
95
|
|
|
*/ |
|
96
|
|
|
public function __construct(\IteratorAggregate $compilers) |
|
97
|
|
|
{ |
|
98
|
|
|
|
|
99
|
|
|
// pass primary key + table prefix utility to parent instance |
|
100
|
|
|
parent::__construct($compilers); |
|
101
|
|
|
|
|
102
|
|
|
// compile the SQL statements |
|
103
|
|
|
$this->compile($this->statements); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|