Completed
Push — master ( 30006e...81f604 )
by Tim
9s
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 190
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 190
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Ee\Utils\SqlStatements
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-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Ee\Repositories;
22
23
use TechDivision\Import\Product\Ee\Utils\SqlStatementKeys;
24
25
/**
26
 * Repository class with the SQL statements to use.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import-product-ee
32
 * @link      http://www.techdivision.com
33
 */
34
class SqlStatementRepository extends \TechDivision\Import\Product\Repositories\SqlStatementRepository
35
{
36
37
    /**
38
     * The SQL statements.
39
     *
40
     * @var array
41
     */
42
    private $statements = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
43
        SqlStatementKeys::PRODUCT =>
44
            'SELECT *
45
               FROM catalog_product_entity
46
              WHERE sku = :sku
47
                AND updated_in > unix_timestamp(now())
48
           ORDER BY created_in ASC',
49
        SqlStatementKeys::PRODUCTS =>
50
            'SELECT * FROM catalog_product_entity
51
              WHERE updated_in > unix_timestamp(now())
52
           GROUP BY sku
53
           ORDER BY created_in ASC',
54
        SqlStatementKeys::PRODUCT_DATETIMES =>
55
            'SELECT *
56
               FROM catalog_product_entity_datetime
57
              WHERE row_id = :pk
58
                AND store_id = :store_id',
59
        SqlStatementKeys::PRODUCT_DECIMALS =>
60
            'SELECT *
61
               FROM catalog_product_entity_decimal
62
              WHERE row_id = :pk
63
                AND store_id = :store_id',
64
        SqlStatementKeys::PRODUCT_INTS =>
65
            'SELECT *
66
               FROM catalog_product_entity_int
67
              WHERE row_id = :pk
68
                AND store_id = :store_id',
69
        SqlStatementKeys::PRODUCT_TEXTS =>
70
            'SELECT *
71
               FROM catalog_product_entity_text
72
              WHERE row_id = :pk
73
                AND store_id = :store_id',
74
        SqlStatementKeys::PRODUCT_VARCHARS =>
75
            'SELECT *
76
               FROM catalog_product_entity_varchar
77
              WHERE row_id = :pk
78
                AND store_id = :store_id',
79
        SqlStatementKeys::CREATE_SEQUENCE_PRODUCT =>
80
            'INSERT INTO sequence_product VALUES ()',
81
        SqlStatementKeys::CREATE_PRODUCT =>
82
            'INSERT
83
               INTO catalog_product_entity
84
                    (entity_id,
85
                     created_in,
86
                     updated_in,
87
                     sku,
88
                     created_at,
89
                     updated_at,
90
                     has_options,
91
                     required_options,
92
                     type_id,
93
                     attribute_set_id)
94
             VALUES (:entity_id,
95
                     :created_in,
96
                     :updated_in,
97
                     :sku,
98
                     :created_at,
99
                     :updated_at,
100
                     :has_options,
101
                     :required_options,
102
                     :type_id,
103
                     :attribute_set_id)',
104
        SqlStatementKeys::UPDATE_PRODUCT =>
105
            'UPDATE catalog_product_entity
106
                SET entity_id = :entity_id,
107
                    created_in = :created_in,
108
                    updated_in = :updated_in,
109
                    sku = :sku,
110
                    created_at = :created_at,
111
                    updated_at = :updated_at,
112
                    has_options = :has_options,
113
                    required_options = :required_options,
114
                    type_id = :type_id,
115
                    attribute_set_id = :attribute_set_id
116
              WHERE row_id = :row_id',
117
        SqlStatementKeys::CREATE_PRODUCT_DATETIME =>
118
            'INSERT
119
               INTO catalog_product_entity_datetime
120
                    (row_id,
121
                     attribute_id,
122
                     store_id,
123
                     value)
124
             VALUES (:row_id,
125
                     :attribute_id,
126
                     :store_id,
127
                     :value)',
128
        SqlStatementKeys::UPDATE_PRODUCT_DATETIME =>
129
            'UPDATE catalog_product_entity_datetime
130
                SET row_id = :row_id,
131
                    attribute_id = :attribute_id,
132
                    store_id = :store_id,
133
                    value = :value
134
              WHERE value_id = :value_id',
135
        SqlStatementKeys::CREATE_PRODUCT_DECIMAL =>
136
            'INSERT
137
               INTO catalog_product_entity_decimal
138
                    (row_id,
139
                     attribute_id,
140
                     store_id,
141
                     value)
142
             VALUES (:row_id,
143
                     :attribute_id,
144
                     :store_id,
145
                     :value)',
146
        SqlStatementKeys::UPDATE_PRODUCT_DECIMAL =>
147
            'UPDATE catalog_product_entity_decimal
148
                SET row_id = :row_id,
149
                    attribute_id = :attribute_id,
150
                    store_id = :store_id,
151
                    value = :value
152
              WHERE value_id = :value_id',
153
        SqlStatementKeys::CREATE_PRODUCT_INT =>
154
            'INSERT
155
               INTO catalog_product_entity_int
156
                    (row_id,
157
                     attribute_id,
158
                     store_id,
159
                     value)
160
             VALUES (:row_id,
161
                     :attribute_id,
162
                     :store_id,
163
                     :value)',
164
        SqlStatementKeys::UPDATE_PRODUCT_INT =>
165
            'UPDATE catalog_product_entity_int
166
                SET row_id = :row_id,
167
                    attribute_id = :attribute_id,
168
                    store_id = :store_id,
169
                    value = :value
170
              WHERE value_id = :value_id',
171
        SqlStatementKeys::CREATE_PRODUCT_VARCHAR =>
172
            'INSERT
173
               INTO catalog_product_entity_varchar
174
                    (row_id,
175
                     attribute_id,
176
                     store_id,
177
                     value)
178
             VALUES (:row_id,
179
                     :attribute_id,
180
                     :store_id,
181
                     :value)',
182
        SqlStatementKeys::UPDATE_PRODUCT_VARCHAR =>
183
            'UPDATE catalog_product_entity_varchar
184
                SET row_id = :row_id,
185
                    attribute_id = :attribute_id,
186
                    store_id = :store_id,
187
                    value = :value
188
              WHERE value_id = :value_id',
189
        SqlStatementKeys::CREATE_PRODUCT_TEXT =>
190
            'INSERT
191
               INTO catalog_product_entity_text
192
                    (row_id,
193
                     attribute_id,
194
                     store_id,
195
                     value)
196
             VALUES (:row_id,
197
                     :attribute_id,
198
                     :store_id,
199
                     :value)',
200
        SqlStatementKeys::UPDATE_PRODUCT_TEXT =>
201
            'UPDATE catalog_product_entity_text
202
                SET row_id = :row_id,
203
                    attribute_id = :attribute_id,
204
                    store_id = :store_id,
205
                    value = :value
206
              WHERE value_id = :value_id'
207
    );
208
209
    /**
210
     * Initialize the the SQL statements.
211
     */
212
    public function __construct()
213
    {
214
215
        // call the parent constructor
216
        parent::__construct();
217
218
        // merge the class statements
219
        foreach ($this->statements as $key => $statement) {
220
            $this->preparedStatements[$key] = $statement;
221
        }
222
    }
223
}
224