Completed
Push — master ( 0aa535...86e6f5 )
by Tim
07:02
created

SqlStatements::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Media\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-media
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Media\Utils;
22
23
use TechDivision\Import\Utils\AbstractSqlStatements;
24
25
/**
26
 * A SSB providing process registry functionality.
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-media
32
 * @link      http://www.techdivision.com
33
 */
34
class SqlStatements extends AbstractSqlStatements
35
{
36
37
    /**
38
     * The SQL statement to load an existing product media gallery by attribute ID + value.
39
     *
40
     * @var string
41
     */
42
    const PRODUCT_MEDIA_GALLERY = 'product_media_gallery';
43
44
    /**
45
     * The SQL statement to load an existing product media gallery by value/store/entity ID.
46
     *
47
     * @var string
48
     */
49
    const PRODUCT_MEDIA_GALLERY_VALUE = 'product_media_gallery_value';
50
51
    /**
52
     * The SQL statement to load an existing product media gallery value to entity by value/entity ID.
53
     *
54
     * @var string
55
     */
56
    const PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY = 'product_media_gallery_value_to_entity';
57
58
    /**
59
     * The SQL statement to create a new product media gallery entry.
60
     *
61
     * @var string
62
     */
63
    const CREATE_PRODUCT_MEDIA_GALLERY = 'create.product_media_gallery';
64
65
    /**
66
     * The SQL statement to update an existing product media gallery entry.
67
     *
68
     * @var string
69
     */
70
    const UPDATE_PRODUCT_MEDIA_GALLERY = 'update.product_media_gallery';
71
72
    /**
73
     * The SQL statement to create a new product media gallery value entry.
74
     *
75
     * @var string
76
     */
77
    const CREATE_PRODUCT_MEDIA_GALLERY_VALUE = 'create.product_media_gallery_value';
78
79
    /**
80
     * The SQL statement to update an existing product media gallery value entry.
81
     *
82
     * @var string
83
     */
84
    const UPDATE_PRODUCT_MEDIA_GALLERY_VALUE = 'update.product_media_gallery_value';
85
86
    /**
87
     * The SQL statement to create a new product media gallery value to entity entry.
88
     *
89
     * @var string
90
     */
91
    const CREATE_PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY = 'create.product_media_gallery_value_to_entity';
92
93
    /**
94
     * The SQL statement to create a new product media gallery value vidoe entry.
95
     *
96
     * @var string
97
     */
98
    const CREATE_PRODUCT_MEDIA_GALLERY_VALUE_VIDEO = 'create.product_media_gallery_value_video';
99
100
    /**
101
     * The SQL statements.
102
     *
103
     * @var array
104
     */
105
    private $statements = array(
106
        SqlStatements::PRODUCT_MEDIA_GALLERY =>
107
            'SELECT *
108
               FROM catalog_product_entity_media_gallery
109
              WHERE attribute_id = :attribute_id
110
                AND value = :value',
111
        SqlStatements::PRODUCT_MEDIA_GALLERY_VALUE =>
112
            'SELECT *
113
               FROM catalog_product_entity_media_gallery_value
114
              WHERE value_id = :value_id
115
                AND store_id = :store_id
116
                AND entity_id = :entity_id',
117
        SqlStatements::PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
118
            'SELECT *
119
               FROM catalog_product_entity_media_gallery_value_to_entity
120
              WHERE value_id = :value_id
121
                AND entity_id = :entity_id',
122
        SqlStatements::CREATE_PRODUCT_MEDIA_GALLERY =>
123
            'INSERT
124
               INTO catalog_product_entity_media_gallery
125
                    (attribute_id,
126
                     value,
127
                     media_type,
128
                     disabled)
129
             VALUES (:attribute_id,
130
                     :value,
131
                     :media_type,
132
                     :disabled)',
133
        SqlStatements::UPDATE_PRODUCT_MEDIA_GALLERY =>
134
            'UPDATE catalog_product_entity_media_gallery
135
                SET attribute_id = :attribute_id,
136
                    value = :value,
137
                    media_type = :media_type,
138
                    disabled = :disabled
139
              WHERE value_id = :value_id',
140
        SqlStatements::CREATE_PRODUCT_MEDIA_GALLERY_VALUE =>
141
            'INSERT
142
               INTO catalog_product_entity_media_gallery_value
143
                    (value_id,
144
                     store_id,
145
                     entity_id,
146
                     label,
147
                     position,
148
                     disabled)
149
             VALUES (:value_id,
150
                     :store_id,
151
                     :entity_id,
152
                     :label,
153
                     :position,
154
                     :disabled)',
155
        SqlStatements::UPDATE_PRODUCT_MEDIA_GALLERY_VALUE =>
156
            'UPDATE catalog_product_entity_media_gallery_value
157
                SET value_id = :value_id,
158
                    store_id = :store_id,
159
                    entity_id = :entity_id,
160
                    label = :label,
161
                    position = :position,
162
                    disabled = :disabled
163
              WHERE record_id = :record_id',
164
        SqlStatements::CREATE_PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
165
            'INSERT
166
               INTO catalog_product_entity_media_gallery_value_to_entity
167
                    (value_id,
168
                     entity_id)
169
             VALUES (:value_id,
170
                     :entity_id)',
171
        SqlStatements::CREATE_PRODUCT_MEDIA_GALLERY_VALUE_VIDEO =>
172
            'INSERT
173
                INTO catalog_product_entity_media_gallery_value_video
174
                     (value_id,
175
                      store_id,
176
                      provider,
177
                      url,
178
                      title,
179
                      description,
180
                      metadata)
181
              VALUES (:value_id,
182
                      :store_id,
183
                      :provider,
184
                      :url,
185
                      :title,
186
                      :description,
187
                      :metadata)'
188
    );
189
190
    /**
191
     * Initialize the the SQL statements.
192
     */
193
    public function __construct()
194
    {
195
196
        // merge the class statements
197
        foreach ($this->statements as $key => $statement) {
198
            $this->preparedStatements[$key] = $statement;
199
        }
200
    }
201
}
202