Completed
Push — master ( c165da...12dd09 )
by Tim
16s
created

SqlStatements::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\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
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Utils;
22
23
/**
24
 * Utility class with the SQL statements to use.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2016 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/techdivision/import-product
30
 * @link      http://www.techdivision.com
31
 */
32
class SqlStatements extends \TechDivision\Import\Utils\SqlStatements
33
{
34
35
    /**
36
     * The SQL statement to load the product with the passed SKU.
37
     *
38
     * @var string
39
     */
40
    const PRODUCT = 'product';
41
42
    /**
43
     * The SQL statement to load the product website relations with the passed product/website ID.
44
     *
45
     * @var string
46
     */
47
    const PRODUCT_WEBSITE = 'product_website';
48
49
    /**
50
     * The SQL statement to load the product datetime attribute with the passed entity/attribute/store ID.
51
     *
52
     * @var string
53
     */
54
    const PRODUCT_DATETIME = 'product_datetime';
55
56
    /**
57
     * The SQL statement to load the product decimal attribute with the passed entity/attribute/store ID.
58
     *
59
     * @var string
60
     */
61
    const PRODUCT_DECIMAL = 'product_decimal';
62
63
    /**
64
     * The SQL statement to load the product integer attribute with the passed entity/attribute/store ID.
65
     *
66
     * @var string
67
     */
68
    const PRODUCT_INT = 'product_int';
69
70
    /**
71
     * The SQL statement to load the product text attribute with the passed entity/attribute/store ID.
72
     *
73
     * @var string
74
     */
75
    const PRODUCT_TEXT = 'product_text';
76
77
    /**
78
     * The SQL statement to load the product varchar attribute with the passed entity/attribute/store ID.
79
     *
80
     * @var string
81
     */
82
    const PRODUCT_VARCHAR = 'product_varchar';
83
84
    /**
85
     * The SQL statement to load a product varchar attribute by the passed attribute code,
86
     * entity typy and store ID as well as the passed value.
87
     *
88
     * @var string
89
     */
90
    const PRODUCT_VARCHAR_BY_ATTRIBUTE_CODE_AND_ENTITY_TYPE_ID_AND_STORE_ID_AND_VALUE = 'product_varchar.by.attribute_code.and.entity_type_id.and.store_id.and.value';
91
92
    /**
93
     * The SQL statement to load the category product relations with the passed product/website ID.
94
     *
95
     * @var string
96
     */
97
    const CATEGORY_PRODUCT = 'category_product';
98
99
    /**
100
     * The SQL statement to load the stock status with the passed product/website/stock ID.
101
     *
102
     * @var string
103
     */
104
    const STOCK_STATUS = 'stock_status';
105
106
    /**
107
     * The SQL statement to load the stock item with the passed product/website/stock ID.
108
     *
109
     * @var string
110
     */
111
    const STOCK_ITEM = 'stock_item';
112
113
    /**
114
     * The SQL statement to create new products.
115
     *
116
     * @var string
117
     */
118
    const CREATE_PRODUCT = 'create.product';
119
120
    /**
121
     * The SQL statement to update an existing product.
122
     *
123
     * @var string
124
     */
125
    const UPDATE_PRODUCT = 'update.product';
126
127
    /**
128
     * The SQL statement to create a new product website relation.
129
     *
130
     * @var string
131
     */
132
    const CREATE_PRODUCT_WEBSITE = 'create.product_website';
133
134
    /**
135
     * The SQL statement to create a new category product relation.
136
     *
137
     * @var string
138
     */
139
    const CREATE_CATEGORY_PRODUCT = 'create.category_product';
140
141
    /**
142
     * The SQL statement to update an existing category product relation.
143
     *
144
     * @var string
145
     */
146
    const UPDATE_CATEGORY_PRODUCT = 'update.category_product';
147
148
    /**
149
     * The SQL statement to create a new product datetime value.
150
     *
151
     * @var string
152
     */
153
    const CREATE_PRODUCT_DATETIME = 'create.product_datetime';
154
155
    /**
156
     * The SQL statement to update an existing product datetime value.
157
     *
158
     * @var string
159
     */
160
    const UPDATE_PRODUCT_DATETIME = 'update.product_datetime';
161
162
    /**
163
     * The SQL statement to create a new product decimal value.
164
     *
165
     * @var string
166
     */
167
    const CREATE_PRODUCT_DECIMAL = 'create.product_decimal';
168
169
    /**
170
     * The SQL statement to update an existing product decimal value.
171
     *
172
     * @var string
173
     */
174
    const UPDATE_PRODUCT_DECIMAL = 'update.product_decimal';
175
176
    /**
177
     * The SQL statement to create a new product integer value.
178
     *
179
     * @var string
180
     */
181
    const CREATE_PRODUCT_INT = 'create.product.int';
182
183
    /**
184
     * The SQL statement to update an existing product integer value.
185
     *
186
     * @var string
187
     */
188
    const UPDATE_PRODUCT_INT = 'update.product_int';
189
190
    /**
191
     * The SQL statement to create a new product varchar value.
192
     *
193
     * @var string
194
     */
195
    const CREATE_PRODUCT_VARCHAR = 'create.product_varchar';
196
197
    /**
198
     * The SQL statement to update an existing product varchar value.
199
     *
200
     * @var string
201
     */
202
    const UPDATE_PRODUCT_VARCHAR = 'update.product_varchar';
203
204
    /**
205
     * The SQL statement to create a new product text value.
206
     *
207
     * @var string
208
     */
209
    const CREATE_PRODUCT_TEXT = 'create.product_text';
210
211
    /**
212
     * The SQL statement to update an existing product text value.
213
     *
214
     * @var string
215
     */
216
    const UPDATE_PRODUCT_TEXT = 'update.product_text';
217
218
    /**
219
     * The SQL statement to create a product's stock status.
220
     *
221
     * @var string
222
     */
223
    const CREATE_STOCK_STATUS = 'create.stock_status';
224
225
    /**
226
     * The SQL statement to update an existing stock status.
227
     *
228
     * @var string
229
     */
230
    const UPDATE_STOCK_STATUS = 'update.stock_status';
231
232
    /**
233
     * The SQL statement to create a product's stock status.
234
     *
235
     * @var string
236
     */
237
    const CREATE_STOCK_ITEM = 'create.stock_item';
238
239
    /**
240
     * The SQL statement to create a product's stock status.
241
     *
242
     * @var string
243
     */
244
    const UPDATE_STOCK_ITEM = 'update.stock_item';
245
246
    /**
247
     * The SQL statement to create new URL rewrites.
248
     *
249
     * @var string
250
     */
251
    const CREATE_URL_REWRITE = 'create.url_rewrite';
252
253
    /**
254
     * The SQL statement to update an existing URL rewrite.
255
     *
256
     * @var string
257
     */
258
    const UPDATE_URL_REWRITE = 'update.url_rewrite';
259
260
    /**
261
     * The SQL statement to create new URL rewrite product category relations.
262
     *
263
     * @var string
264
     */
265
    const CREATE_URL_REWRITE_PRODUCT_CATEGORY = 'create.url_rewrite_product_category';
266
267
    /**
268
     * The SQL statement to update an existing URL rewrite product category relation.
269
     *
270
     * @var string
271
     */
272
    const UPDATE_URL_REWRITE_PRODUCT_CATEGORY = 'update.url_rewrite_product_category';
273
274
    /**
275
     * The SQL statement to remove a existing URL rewrite product category relation.
276
     *
277
     * @var string
278
     */
279
    const DELETE_URL_REWRITE_PRODUCT_CATEGORY = 'delete.url_rewrite_product_category';
280
281
    /**
282
     * The SQL statement to remove a existing product.
283
     *
284
     * @var string
285
     */
286
    const DELETE_PRODUCT = 'delete.product';
287
288
    /**
289
     * The SQL statement to remove all existing stock status related with the SKU passed as parameter.
290
     *
291
     * @var string
292
     */
293
    const DELETE_STOCK_STATUS_BY_SKU = 'delete.stock_status.by.sku';
294
295
    /**
296
     * The SQL statement to remove all existing stock item related with the SKU passed as parameter.
297
     *
298
     * @var string
299
     */
300
    const DELETE_STOCK_ITEM_BY_SKU = 'delete.stock_item.by.sku';
301
302
    /**
303
     * The SQL statement to remove all product website relations for the product with the SKU passed as parameter.
304
     *
305
     * @var string
306
     */
307
    const DELETE_PRODUCT_WEBSITE_BY_SKU = 'delete.product_website.by.sku';
308
309
    /**
310
     * The SQL statement to remove all product category relations for the product with the SKU passed as parameter.
311
     *
312
     * @var string
313
     */
314
    const DELETE_CATEGORY_PRODUCT_BY_SKU = 'delete.category_product.by.sku';
315
316
    /**
317
     * The SQL statement to load the URL rewrite product category relation for the passed product/category ID.
318
     *
319
     * @var string
320
     */
321
    const URL_REWRITE_PRODUCT_CATEGORY_BY_PRODUCT_ID_AND_CATEGORY_ID = 'ur_rewrite_product_category.by.product_id.and.category_id';
322
323
    /**
324
     * The SQL statements.
325
     *
326
     * @var array
327
     */
328
    private $statements = array(
329
        SqlStatements::PRODUCT =>
330
            'SELECT * FROM catalog_product_entity WHERE sku = :sku',
331
        SqlStatements::PRODUCT_WEBSITE =>
332
            'SELECT * FROM catalog_product_website WHERE product_id = :product_id AND website_id = :website_id',
333
        SqlStatements::PRODUCT_DATETIME =>
334
            'SELECT *
335
               FROM catalog_product_entity_datetime
336
              WHERE entity_id = :entity_id
337
                AND attribute_id = :attribute_id
338
                AND store_id = :store_id',
339
        SqlStatements::PRODUCT_DECIMAL =>
340
            'SELECT *
341
               FROM catalog_product_entity_decimal
342
              WHERE entity_id = :entity_id
343
                AND attribute_id = :attribute_id
344
                AND store_id = :store_id',
345
        SqlStatements::PRODUCT_INT =>
346
            'SELECT *
347
               FROM catalog_product_entity_int
348
              WHERE entity_id = :entity_id
349
                AND attribute_id = :attribute_id
350
                AND store_id = :store_id',
351
        SqlStatements::PRODUCT_TEXT =>
352
            'SELECT *
353
               FROM catalog_product_entity_text
354
              WHERE entity_id = :entity_id
355
                AND attribute_id = :attribute_id
356
                AND store_id = :store_id',
357
        SqlStatements::PRODUCT_VARCHAR =>
358
            'SELECT *
359
               FROM catalog_product_entity_varchar
360
              WHERE entity_id = :entity_id
361
                AND attribute_id = :attribute_id
362
                AND store_id = :store_id',
363
        SqlStatements::PRODUCT_VARCHAR_BY_ATTRIBUTE_CODE_AND_ENTITY_TYPE_ID_AND_STORE_ID_AND_VALUE =>
364
            'SELECT t1.*
365
               FROM catalog_product_entity_varchar t1,
366
                    eav_attribute t2
367
              WHERE t2.attribute_code = :attribute_code
368
                AND t2.entity_type_id = :entity_type_id
369
                AND t1.attribute_id = t2.attribute_id
370
                AND t1.store_id = :store_id
371
                AND t1.value = :value',
372
        SqlStatements::CATEGORY_PRODUCT =>
373
            'SELECT * FROM catalog_category_product WHERE category_id = :category_id AND product_id = :product_id',
374
        SqlStatements::STOCK_STATUS =>
375
            'SELECT * FROM cataloginventory_stock_status WHERE product_id = :product_id AND website_id = :website_id AND stock_id = :stock_id',
376
        SqlStatements::STOCK_ITEM =>
377
            'SELECT * FROM cataloginventory_stock_item WHERE product_id = :product_id AND website_id = :website_id AND stock_id = :stock_id',
378
        SqlStatements::CREATE_PRODUCT =>
379
            'INSERT
380
               INTO catalog_product_entity
381
                    (sku,
382
                     created_at,
383
                     updated_at,
384
                     has_options,
385
                     required_options,
386
                     type_id,
387
                     attribute_set_id)
388
             VALUES (:sku,
389
                     :created_at,
390
                     :updated_at,
391
                     :has_options,
392
                     :required_options,
393
                     :type_id,
394
                     :attribute_set_id)',
395
        SqlStatements::UPDATE_PRODUCT =>
396
            'UPDATE catalog_product_entity
397
                SET sku = :sku,
398
                   created_at = :created_at,
399
                    updated_at = :updated_at,
400
                    has_options = :has_options,
401
                    required_options = :required_options,
402
                    type_id = :type_id,
403
                    attribute_set_id = :attribute_set_id
404
              WHERE entity_id = :entity_id',
405
        SqlStatements::CREATE_PRODUCT_WEBSITE =>
406
            'INSERT
407
               INTO catalog_product_website
408
                    (product_id,
409
                     website_id)
410
             VALUES (:product_id,
411
                     :website_id)',
412
        SqlStatements::CREATE_CATEGORY_PRODUCT =>
413
            'INSERT
414
               INTO catalog_category_product
415
                    (category_id,
416
                     product_id,
417
                     position)
418
             VALUES (:category_id,
419
                     :product_id,
420
                     :position)',
421
        SqlStatements::UPDATE_CATEGORY_PRODUCT =>
422
            'UPDATE catalog_category_product
423
                SET category_id = :category_id,
424
                    product_id = :product_id,
425
                    position = :position
426
             WHERE  entity_id = :entity_id',
427
        SqlStatements::CREATE_PRODUCT_DATETIME =>
428
            'INSERT
429
               INTO catalog_product_entity_datetime
430
                    (entity_id,
431
                     attribute_id,
432
                     store_id,
433
                     value)
434
            VALUES (:entity_id,
435
                    :attribute_id,
436
                    :store_id,
437
                    :value)',
438
        SqlStatements::UPDATE_PRODUCT_DATETIME =>
439
            'UPDATE catalog_product_entity_datetime
440
                SET entity_id = :entity_id,
441
                    attribute_id = :attribute_id,
442
                    store_id = :store_id,
443
                    value = :value
444
              WHERE value_id = :value_id',
445
        SqlStatements::CREATE_PRODUCT_DECIMAL =>
446
            'INSERT
447
               INTO catalog_product_entity_decimal
448
                    (entity_id,
449
                     attribute_id,
450
                     store_id,
451
                     value)
452
            VALUES (:entity_id,
453
                    :attribute_id,
454
                    :store_id,
455
                    :value)',
456
        SqlStatements::UPDATE_PRODUCT_DECIMAL =>
457
            'UPDATE catalog_product_entity_decimal
458
                SET entity_id = :entity_id,
459
                    attribute_id = :attribute_id,
460
                    store_id = :store_id,
461
                    value = :value
462
              WHERE value_id = :value_id',
463
        SqlStatements::CREATE_PRODUCT_INT =>
464
            'INSERT
465
               INTO catalog_product_entity_int
466
                    (entity_id,
467
                     attribute_id,
468
                     store_id,
469
                     value)
470
             VALUES (:entity_id,
471
                     :attribute_id,
472
                     :store_id,
473
                     :value)',
474
        SqlStatements::UPDATE_PRODUCT_INT =>
475
            'UPDATE catalog_product_entity_int
476
                SET entity_id = :entity_id,
477
                    attribute_id = :attribute_id,
478
                    store_id = :store_id,
479
                    value = :value
480
              WHERE value_id = :value_id',
481
        SqlStatements::CREATE_PRODUCT_VARCHAR =>
482
            'INSERT
483
               INTO catalog_product_entity_varchar
484
                    (entity_id,
485
                     attribute_id,
486
                     store_id,
487
                     value)
488
             VALUES (:entity_id,
489
                     :attribute_id,
490
                     :store_id,
491
                     :value)',
492
        SqlStatements::UPDATE_PRODUCT_VARCHAR =>
493
            'UPDATE catalog_product_entity_varchar
494
                SET entity_id = :entity_id,
495
                    attribute_id = :attribute_id,
496
                    store_id = :store_id,
497
                    value = :value
498
              WHERE value_id = :value_id',
499
        SqlStatements::CREATE_PRODUCT_TEXT =>
500
            'INSERT
501
               INTO catalog_product_entity_text
502
                    (entity_id,
503
                     attribute_id,
504
                     store_id,
505
                     value)
506
             VALUES (:entity_id,
507
                     :attribute_id,
508
                     :store_id,
509
                     :value)',
510
        SqlStatements::UPDATE_PRODUCT_TEXT =>
511
            'UPDATE catalog_product_entity_text
512
                SET entity_id = :entity_id,
513
                    attribute_id = :attribute_id,
514
                    store_id = :store_id,
515
                    value = :value
516
              WHERE value_id = :value_id',
517
        SqlStatements::CREATE_STOCK_STATUS =>
518
            'INSERT
519
               INTO cataloginventory_stock_status
520
                    (product_id,
521
                     website_id,
522
                     stock_id,
523
                     qty,
524
                     stock_status)
525
             VALUES (:product_id,
526
                     :website_id,
527
                     :stock_id,
528
                     :qty,
529
                     :stock_status)',
530
        SqlStatements::UPDATE_STOCK_STATUS =>
531
            'UPDATE cataloginventory_stock_status
532
                SET qty = :qty,
533
                    stock_status = :stock_status
534
              WHERE product_id = :product_id
535
                AND website_id = :website_id
536
                AND stock_id = :stock_id',
537
        SqlStatements::CREATE_STOCK_ITEM =>
538
            'INSERT
539
               INTO cataloginventory_stock_item
540
                    (product_id,
541
                     stock_id,
542
                     website_id,
543
                     qty,
544
                     min_qty,
545
                     use_config_min_qty,
546
                     is_qty_decimal,
547
                     backorders,
548
                     use_config_backorders,
549
                     min_sale_qty,
550
                     use_config_min_sale_qty,
551
                     max_sale_qty,
552
                     use_config_max_sale_qty,
553
                     is_in_stock,
554
                     notify_stock_qty,
555
                     use_config_notify_stock_qty,
556
                     manage_stock,
557
                     use_config_manage_stock,
558
                     use_config_qty_increments,
559
                     qty_increments,
560
                     use_config_enable_qty_inc,
561
                     enable_qty_increments,
562
                     is_decimal_divided)
563
            VALUES (:product_id,
564
                    :stock_id,
565
                    :website_id,
566
                    :qty,
567
                    :min_qty,
568
                    :use_config_min_qty,
569
                    :is_qty_decimal,
570
                    :backorders,
571
                    :use_config_backorders,
572
                    :min_sale_qty,
573
                    :use_config_min_sale_qty,
574
                    :max_sale_qty,
575
                    :use_config_max_sale_qty,
576
                    :is_in_stock,
577
                    :notify_stock_qty,
578
                    :use_config_notify_stock_qty,
579
                    :manage_stock,
580
                    :use_config_manage_stock,
581
                    :use_config_qty_increments,
582
                    :qty_increments,
583
                    :use_config_enable_qty_inc,
584
                    :enable_qty_increments,
585
                    :is_decimal_divided)',
586
        SqlStatements::UPDATE_STOCK_ITEM =>
587
            'UPDATE cataloginventory_stock_item
588
                SET product_id = :product_id,
589
                   stock_id = :stock_id,
590
                   website_id = :website_id,
591
                   qty = :qty,
592
                   min_qty = :min_qty,
593
                   use_config_min_qty = :use_config_min_qty,
594
                   is_qty_decimal = :is_qty_decimal,
595
                   backorders = :backorders,
596
                   use_config_backorders = :use_config_backorders,
597
                   min_sale_qty = :min_sale_qty,
598
                   use_config_min_sale_qty = :use_config_min_sale_qty,
599
                   max_sale_qty = :max_sale_qty,
600
                   use_config_max_sale_qty = :use_config_max_sale_qty,
601
                   is_in_stock = :is_in_stock,
602
                   low_stock_date = :low_stock_date,
603
                   notify_stock_qty = :notify_stock_qty,
604
                   use_config_notify_stock_qty = :use_config_notify_stock_qty,
605
                   manage_stock = :manage_stock,
606
                   use_config_manage_stock = :use_config_manage_stock,
607
                   stock_status_changed_auto = :stock_status_changed_auto,
608
                   use_config_qty_increments = :use_config_qty_increments,
609
                   qty_increments = :qty_increments,
610
                   use_config_enable_qty_inc = :use_config_enable_qty_inc,
611
                   enable_qty_increments = :enable_qty_increments,
612
                   is_decimal_divided = :is_decimal_divided
613
             WHERE item_id = :item_id',
614
        SqlStatements::CREATE_URL_REWRITE =>
615
            'INSERT
616
               INTO url_rewrite
617
                    (entity_type,
618
                     entity_id,
619
                     request_path,
620
                     target_path,
621
                     redirect_type,
622
                     store_id,
623
                     description,
624
                     is_autogenerated,
625
                     metadata)
626
            VALUES (:entity_type,
627
                    :entity_id,
628
                    :request_path,
629
                    :target_path,
630
                    :redirect_type,
631
                    :store_id,
632
                    :description,
633
                    :is_autogenerated,
634
                    :metadata)',
635
        SqlStatements::UPDATE_URL_REWRITE =>
636
            'UPDATE url_rewrite
637
                SET entity_type = :entity_type,
638
                    entity_id = :entity_id,
639
                    request_path = :request_path,
640
                    target_path = :target_path,
641
                    redirect_type = :redirect_type,
642
                    store_id = :store_id,
643
                    description = :description,
644
                    is_autogenerated = :is_autogenerated,
645
                    metadata = :metadata
646
              WHERE url_rewrite_id = :url_rewrite_id',
647
        SqlStatements::CREATE_URL_REWRITE_PRODUCT_CATEGORY =>
648
            'INSERT
649
               INTO catalog_url_rewrite_product_category
650
                    (url_rewrite_id,
651
                     category_id,
652
                     product_id)
653
             VALUES (:url_rewrite_id,
654
                     :category_id,
655
                     :product_id)',
656
        SqlStatements::UPDATE_URL_REWRITE_PRODUCT_CATEGORY =>
657
            'UPDATE catalog_url_rewrite_product_category
658
                SET url_rewrite_id = :url_rewrite_id
659
              WHERE category_id = :category_id
660
                AND product_id = :product_id',
661
        SqlStatements::DELETE_URL_REWRITE_PRODUCT_CATEGORY =>
662
            'DELETE
663
               FROM catalog_url_rewrite_product_category
664
              WHERE url_rewrite_id = :url_rewrite_id',
665
        SqlStatements::DELETE_PRODUCT =>
666
            'DELETE
667
               FROM catalog_product_entity
668
              WHERE sku = :sku',
669
        SqlStatements::DELETE_STOCK_STATUS_BY_SKU =>
670
            'DELETE cataloginventory_stock_status
671
               FROM cataloginventory_stock_status
672
         INNER JOIN catalog_product_entity
673
              WHERE catalog_product_entity.sku = :sku
674
                AND cataloginventory_stock_status.product_id = catalog_product_entity.entity_id',
675
        SqlStatements::DELETE_STOCK_ITEM_BY_SKU =>
676
            'DELETE cataloginventory_stock_item
677
               FROM cataloginventory_stock_item
678
         INNER JOIN catalog_product_entity
679
              WHERE catalog_product_entity.sku = :sku
680
                AND cataloginventory_stock_item.product_id = catalog_product_entity.entity_id',
681
        SqlStatements::DELETE_PRODUCT_WEBSITE_BY_SKU =>
682
            'DELETE catalog_product_website
683
               FROM catalog_product_website
684
         INNER JOIN catalog_product_entity
685
              WHERE catalog_product_entity.sku = :sku
686
                AND catalog_product_website.product_id = catalog_product_entity.entity_id',
687
        SqlStatements::DELETE_CATEGORY_PRODUCT_BY_SKU =>
688
            'DELETE catalog_category_product
689
               FROM catalog_category_product
690
         INNER JOIN catalog_product_entity
691
              WHERE catalog_product_entity.sku = :sku
692
                AND catalog_category_product.product_id = catalog_product_entity.entity_id',
693
        SqlStatements::URL_REWRITE_PRODUCT_CATEGORY_BY_PRODUCT_ID_AND_CATEGORY_ID =>
694
            'SELECT *
695
               FROM catalog_url_rewrite_product_category
696
              WHERE product_id = :product_id
697
                AND category_id = :category_id'
698
    );
699
700
    /**
701
     * Initialize the the SQL statements.
702
     */
703
    public function __construct()
704
    {
705
706
        // call the parent constructor
707
        parent::__construct();
0 ignored issues
show
Bug introduced by
The method __construct() cannot be called from this context as it is declared private in class TechDivision\Import\Utils\SqlStatements.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
Unused Code introduced by
The call to the method TechDivision\Import\Util...atements::__construct() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
708
709
        // merge the class statements
710
        foreach ($this->statements as $key => $statement) {
711
            $this->preparedStatements[$key] = $statement;
0 ignored issues
show
Bug introduced by
The property preparedStatements does not seem to exist. Did you mean statements?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
712
        }
713
    }
714
}
715