Completed
Push — master ( bee8e3...55c52a )
by Tim
12s
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
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Variant\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-variant
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Variant\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-variant
30
 * @link      http://www.techdivision.com
31
 */
32
class SqlStatements extends \TechDivision\Import\Product\Utils\SqlStatements
33
{
34
35
    /**
36
     * The SQL statement to load an existing product relation with the passed parent/child ID.
37
     *
38
     * @var string
39
     */
40
    const PRODUCT_RELATION = 'product_relation';
41
42
    /**
43
     * The SQL statement to load an existing product super link with the passed prodcut/parent ID.
44
     *
45
     * @var string
46
     */
47
    const PRODUCT_SUPER_LINK = 'product_super_link';
48
49
    /**
50
     * The SQL statement to load an existing product super attribute with the passed product/attribute ID.
51
     *
52
     * @var string
53
     */
54
    const PRODUCT_SUPER_ATTRIBUTE = 'product_super_attribute';
55
56
    /**
57
     * The SQL statement to load an existing product super attribute label with the passed product super attribute/store ID.
58
     *
59
     * @var string
60
     */
61
    const PRODUCT_SUPER_ATTRIBUTE_LABEL = 'product_super_attribute_label';
62
63
    /**
64
     * The SQL statement to create a new product relation.
65
     *
66
     * @var string
67
     */
68
    const CREATE_PRODUCT_RELATION = 'create.product_relation';
69
70
    /**
71
     * The SQL statement to create a new product super link.
72
     *
73
     * @var string
74
     */
75
    const CREATE_PRODUCT_SUPER_LINK = 'create.product_super_link';
76
77
    /**
78
     * The SQL statement to create a new product super attribute.
79
     *
80
     * @var string
81
     */
82
    const CREATE_PRODUCT_SUPER_ATTRIBUTE = 'create.product_super_attribute';
83
84
    /**
85
     * The SQL statement to update an existing product super attribute.
86
     *
87
     * @var string
88
     */
89
    const UPDATE_PRODUCT_SUPER_ATTRIBUTE = 'update.product_super_attribute';
90
91
    /**
92
     * The SQL statement to create a new product super attribute label.
93
     *
94
     * @var string
95
     */
96
    const CREATE_PRODUCT_SUPER_ATTRIBUTE_LABEL = 'create.product_super_attribute_label';
97
98
    /**
99
     * The SQL statement to update an existing product super attribute label.
100
     *
101
     * @var string
102
     */
103
    const UPDATE_PRODUCT_SUPER_ATTRIBUTE_LABEL = 'update.product_super_attribute_label';
104
105
    /**
106
     * The SQL statements.
107
     *
108
     * @var array
109
     */
110
    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...
111
        SqlStatements::PRODUCT_RELATION =>
112
            'SELECT *
113
               FROM catalog_product_relation
114
              WHERE parent_id = :parent_id
115
                AND child_id = :child_id',
116
        SqlStatements::PRODUCT_SUPER_LINK =>
117
            'SELECT *
118
               FROM catalog_product_super_link
119
              WHERE product_id = :product_id
120
                AND parent_id = :parent_id',
121
        SqlStatements::PRODUCT_SUPER_ATTRIBUTE =>
122
            'SELECT *
123
               FROM catalog_product_super_attribute
124
              WHERE product_id = :product_id
125
                AND attribute_id = :attribute_id',
126
        SqlStatements::PRODUCT_SUPER_ATTRIBUTE_LABEL =>
127
            'SELECT *
128
               FROM catalog_product_super_attribute_label
129
              WHERE product_super_attribute_id = :product_super_attribute_id
130
                AND store_id = :store_id',
131
        SqlStatements::CREATE_PRODUCT_RELATION =>
132
            'INSERT
133
               INTO catalog_product_relation
134
                    (parent_id,
135
                     child_id)
136
             VALUES (:parent_id,
137
                     :child_id)',
138
        SqlStatements::CREATE_PRODUCT_SUPER_LINK =>
139
            'INSERT
140
               INTO catalog_product_super_link
141
                    (product_id,
142
                     parent_id)
143
             VALUES (:product_id,
144
                     :parent_id)',
145
        SqlStatements::CREATE_PRODUCT_SUPER_ATTRIBUTE =>
146
            'INSERT
147
               INTO catalog_product_super_attribute
148
                    (product_id,
149
                     attribute_id,
150
                     position)
151
             VALUES (:product_id,
152
                     :attribute_id,
153
                     :position)',
154
        SqlStatements::UPDATE_PRODUCT_SUPER_ATTRIBUTE =>
155
            'UPDATE catalog_product_super_attribute
156
                SET product_id = :product_id,
157
                    attribute_id = :attribute_id,
158
                    position = :position
159
              WHERE product_super_attribute_id = :product_super_attribute_id',
160
        SqlStatements::CREATE_PRODUCT_SUPER_ATTRIBUTE_LABEL =>
161
            'INSERT
162
                INTO catalog_product_super_attribute_label
163
                     (product_super_attribute_id,
164
                      store_id,
165
                      use_default,
166
                      value)
167
              VALUES (:product_super_attribute_id,
168
                      :store_id,
169
                      :use_default,
170
                      :value)',
171
        SqlStatements::UPDATE_PRODUCT_SUPER_ATTRIBUTE_LABEL =>
172
            'UPDATE catalog_product_super_attribute_label
173
                SET product_super_attribute_id = :product_super_attribute_id,
174
                    store_id = :store_id,
175
                    use_default = :use_default,
176
                    value = :value
177
              WHERE value_id = :value_id'
178
    );
179
180
    /**
181
     * Initialize the the SQL statements.
182
     */
183
    public function __construct()
184
    {
185
186
        // call the parent constructor
187
        parent::__construct();
188
189
        // merge the class statements
190
        foreach ($this->statements as $key => $statement) {
191
            $this->preparedStatements[$key] = $statement;
192
        }
193
    }
194
}
195