Completed
Push — master ( 5e213d...d2db8d )
by Tim
9s
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 117
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 117
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Media\Repositories\SqlStatementRepository
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\Repositories;
22
23
use TechDivision\Import\Product\Media\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-media
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_MEDIA_GALLERY =>
44
            'SELECT *
45
               FROM catalog_product_entity_media_gallery
46
              WHERE attribute_id = :attribute_id
47
                AND value = :value',
48
        SqlStatementKeys::PRODUCT_MEDIA_GALLERY_VALUE =>
49
            'SELECT *
50
               FROM catalog_product_entity_media_gallery_value
51
              WHERE value_id = :value_id
52
                AND store_id = :store_id
53
                AND entity_id = :entity_id',
54
        SqlStatementKeys::PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
55
            'SELECT *
56
               FROM catalog_product_entity_media_gallery_value_to_entity
57
              WHERE value_id = :value_id
58
                AND entity_id = :entity_id',
59
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY =>
60
            'INSERT
61
               INTO catalog_product_entity_media_gallery
62
                    (attribute_id,
63
                     value,
64
                     media_type,
65
                     disabled)
66
             VALUES (:attribute_id,
67
                     :value,
68
                     :media_type,
69
                     :disabled)',
70
        SqlStatementKeys::UPDATE_PRODUCT_MEDIA_GALLERY =>
71
            'UPDATE catalog_product_entity_media_gallery
72
                SET attribute_id = :attribute_id,
73
                    value = :value,
74
                    media_type = :media_type,
75
                    disabled = :disabled
76
              WHERE value_id = :value_id',
77
        SqlStatementKeys::DELETE_PRODUCT_MEDIA_GALLERY =>
78
            'DELETE
79
               FROM catalog_product_entity_media_gallery
80
              WHERE value_id = :value_id',
81
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY_VALUE =>
82
            'INSERT
83
               INTO catalog_product_entity_media_gallery_value
84
                    (value_id,
85
                     store_id,
86
                     entity_id,
87
                     label,
88
                     position,
89
                     disabled)
90
             VALUES (:value_id,
91
                     :store_id,
92
                     :entity_id,
93
                     :label,
94
                     :position,
95
                     :disabled)',
96
        SqlStatementKeys::UPDATE_PRODUCT_MEDIA_GALLERY_VALUE =>
97
            'UPDATE catalog_product_entity_media_gallery_value
98
                SET value_id = :value_id,
99
                    store_id = :store_id,
100
                    entity_id = :entity_id,
101
                    label = :label,
102
                    position = :position,
103
                    disabled = :disabled
104
              WHERE record_id = :record_id',
105
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
106
            'INSERT
107
               INTO catalog_product_entity_media_gallery_value_to_entity
108
                    (value_id,
109
                     entity_id)
110
             VALUES (:value_id,
111
                     :entity_id)',
112
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY_VALUE_VIDEO =>
113
            'INSERT
114
               INTO catalog_product_entity_media_gallery_value_video
115
                    (value_id,
116
                     store_id,
117
                     provider,
118
                     url,
119
                     title,
120
                     description,
121
                     metadata)
122
             VALUES (:value_id,
123
                     :store_id,
124
                     :provider,
125
                     :url,
126
                     :title,
127
                     :description,
128
                     :metadata)',
129
        SqlStatementKeys::PRODUCT_MEDIA_GALLERIES_BY_SKU =>
130
            'SELECT t3.*
131
               FROM catalog_product_entity t1,
132
                    catalog_product_entity_media_gallery_value_to_entity t2,
133
                    catalog_product_entity_media_gallery t3
134
              WHERE t1.sku = :sku
135
                AND t2.entity_id = t1.entity_id
136
                AND t3.value_id = t2.value_id'
137
    );
138
139
    /**
140
     * Initialize the the SQL statements.
141
     */
142
    public function __construct()
143
    {
144
145
        // merge the class statements
146
        foreach ($this->statements as $key => $statement) {
147
            $this->preparedStatements[$key] = $statement;
148
        }
149
    }
150
}
151