Completed
Push — master ( 5cc256...ffe22f )
by Tim
9s
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 127
ccs 0
cts 6
cp 0
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Bundle\Repositories\SqlStatementKeys
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-bundle
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Bundle\Repositories;
22
23
use TechDivision\Import\Product\Bundle\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-bundle
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::BUNDLE_OPTION =>
44
            'SELECT t0.*
45
               FROM catalog_product_bundle_option t0
46
         INNER JOIN catalog_product_bundle_option_value t1
47
                 ON t0.parent_id = :parent_id
48
                AND t0.option_id = t1.option_id
49
                AND t1.title = :title
50
                AND t1.store_id = :store_id',
51
        SqlStatementKeys::BUNDLE_OPTION_VALUE =>
52
            'SELECT t0.*
53
               FROM catalog_product_bundle_option_value t0
54
         INNER JOIN catalog_product_bundle_option t1
55
                 ON t1.parent_id = :parent_id
56
                AND t0.option_id = t1.option_id
57
                AND t0.title = :title
58
                AND t0.store_id = :store_id',
59
        SqlStatementKeys::BUNDLE_SELECTION =>
60
            'SELECT *
61
               FROM catalog_product_bundle_selection
62
              WHERE option_id = :option_id
63
                AND parent_product_id = :parent_product_id
64
                AND product_id = :product_id',
65
        SqlStatementKeys::BUNDLE_SELECTION_PRICE =>
66
            'SELECT *
67
               FROM catalog_product_bundle_selection_price
68
              WHERE selection_id = :selection_id
69
                AND website_id = :website_id',
70
        SqlStatementKeys::CREATE_PRODUCT_BUNDLE_OPTION =>
71
            'INSERT
72
               INTO catalog_product_bundle_option
73
                    (parent_id,
74
                     required,
75
                     position,
76
                     type)
77
             VALUES (:parent_id,
78
                     :required,
79
                     :position,
80
                     :type)',
81
        SqlStatementKeys::UPDATE_PRODUCT_BUNDLE_OPTION =>
82
            'UPDATE catalog_product_bundle_option
83
                SET parent_id = :parent_id,
84
                    required = :required,
85
                    position = :position,
86
                    type = :type
87
              WHERE option_id = :option_id',
88
        SqlStatementKeys::CREATE_PRODUCT_BUNDLE_OPTION_VALUE =>
89
            'INSERT
90
               INTO catalog_product_bundle_option_value
91
                    (option_id,
92
                     store_id,
93
                     title)
94
             VALUES (:option_id,
95
                     :store_id,
96
                     :title)',
97
        SqlStatementKeys::CREATE_PRODUCT_BUNDLE_SELECTION =>
98
            'INSERT
99
               INTO catalog_product_bundle_selection
100
                    (option_id,
101
                     parent_product_id,
102
                     product_id,
103
                     position,
104
                     is_default,
105
                     selection_price_type,
106
                     selection_price_value,
107
                     selection_qty,
108
                     selection_can_change_qty)
109
             VALUES (:option_id,
110
                     :parent_product_id,
111
                     :product_id,
112
                     :position,
113
                     :is_default,
114
                     :selection_price_type,
115
                     :selection_price_value,
116
                     :selection_qty,
117
                     :selection_can_change_qty)',
118
        SqlStatementKeys::UPDATE_PRODUCT_BUNDLE_SELECTION =>
119
            'UPDATE catalog_product_bundle_selection
120
                SET option_id = :option_id,
121
                    parent_product_id = :parent_product_id,
122
                    product_id = :product_id,
123
                    position = :position,
124
                    is_default = :is_default,
125
                    selection_price_type = :selection_price_type,
126
                    selection_price_value = :selection_price_value,
127
                    selection_qty = :selection_qty,
128
                    selection_can_change_qty = :selection_can_change_qty
129
              WHERE selection_id = :selection_id',
130
        SqlStatementKeys::CREATE_PRODUCT_BUNDLE_SELECTION_PRICE =>
131
            'INSERT
132
               INTO catalog_product_bundle_selection_price
133
                    (selection_id,
134
                     website_id,
135
                     selection_price_type,
136
                     selection_price_value)
137
             VALUES (:selection_id,
138
                     :website_id,
139
                     :selection_price_type,
140
                     :selection_price_value)',
141
        SqlStatementKeys::UPDATE_PRODUCT_BUNDLE_SELECTION_PRICE =>
142
            'UPDATE catalog_product_bundle_selection_price
143
                SET selection_price_type = :selection_price_type,
144
                    selection_price_value = :selection_price_value
145
              WHERE selection_id = :selection_id
146
                AND website_id = :website_id'
147
    );
148
149
    /**
150
     * Initialize the the SQL statements.
151
     */
152
    public function __construct()
153
    {
154
155
        // merge the class statements
156
        foreach ($this->statements as $key => $statement) {
157
            $this->preparedStatements[$key] = $statement;
158
        }
159
    }
160
}
161