Completed
Push — master ( 191fb5...5bfad4 )
by Tim
10s
created

SqlStatementRepository::__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 7
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\Ee\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-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Ee\Repositories;
22
23
use TechDivision\Import\Ee\Utils\SqlStatementKeys;
24
25
/**
26
 * Utility 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-ee
32
 * @link      http://www.techdivision.com
33
 */
34
class SqlStatementRepository extends \TechDivision\Import\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::CATEGORIES =>
44
            'SELECT t0.*,
45
                    (SELECT `value`
46
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
47
                      WHERE t1.attribute_code = \'name\'
48
                        AND t1.entity_type_id = 3
49
                        AND t2.attribute_id = t1.attribute_id
50
                        AND t2.store_id = 0
51
                        AND t2.row_id = t0.row_id) AS name,
52
                    (SELECT `value`
53
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
54
                      WHERE t1.attribute_code = \'url_key\'
55
                        AND t1.entity_type_id = 3
56
                        AND t2.attribute_id = t1.attribute_id
57
                        AND t2.store_id = 0
58
                        AND t2.row_id = t0.row_id) AS url_key,
59
                    (SELECT `value`
60
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
61
                      WHERE t1.attribute_code = \'url_path\'
62
                        AND t1.entity_type_id = 3
63
                        AND t2.attribute_id = t1.attribute_id
64
                        AND t2.store_id = 0
65
                        AND t2.row_id = t0.row_id) AS url_path,
66
                    (SELECT `value`
67
                       FROM eav_attribute t1, catalog_category_entity_int t2
68
                      WHERE t1.attribute_code = \'is_anchor\'
69
                        AND t1.entity_type_id = 3
70
                        AND t2.attribute_id = t1.attribute_id
71
                        AND t2.store_id = 0
72
                        AND t2.row_id = t0.row_id) AS is_anchor
73
               FROM catalog_category_entity AS t0',
74
        SqlStatementKeys::CATEGORIES_BY_STORE_VIEW =>
75
            'SELECT t0.*,
76
                 IF (name_store.value_id > 0, name_store.value, name_default.value) AS name,
77
                 IF (url_key_store.value_id > 0, url_key_store.value, url_key_default.value) AS url_key,
78
                 IF (url_path_store.value_id > 0, url_path_store.value, url_path_default.value) AS url_path,
79
                 IF (is_anchor_store.value_id > 0, is_anchor_store.value, is_anchor_default.value) AS is_anchor
80
               FROM catalog_category_entity AS t0
81
          LEFT JOIN catalog_category_entity_varchar AS name_store
82
                 ON name_store.attribute_id = (
83
                        SELECT attribute_id FROM eav_attribute
84
                        WHERE attribute_code = \'name\' AND entity_type_id = 3
85
                    )
86
                    AND name_store.store_id = :store_id
87
                    AND name_store.row_id = t0.row_id
88
          LEFT JOIN catalog_category_entity_varchar AS name_default
89
                 ON name_default.attribute_id = (
90
                        SELECT attribute_id FROM eav_attribute
91
                        WHERE attribute_code = \'name\' AND entity_type_id = 3
92
                    )
93
                    AND name_default.store_id = 0
94
                    AND name_default.row_id = t0.row_id
95
          LEFT JOIN catalog_category_entity_varchar AS url_key_store
96
                 ON url_key_store.attribute_id = (
97
                        SELECT attribute_id FROM eav_attribute
98
                        WHERE attribute_code = \'url_key\' AND entity_type_id = 3
99
                    )
100
                    AND url_key_store.store_id = :store_id
101
                    AND url_key_store.row_id = t0.row_id
102
          LEFT JOIN catalog_category_entity_varchar AS url_key_default
103
                 ON url_key_default.attribute_id = (
104
                        SELECT attribute_id FROM eav_attribute
105
                        WHERE attribute_code = \'url_key\' AND entity_type_id = 3
106
                    )
107
                    AND url_key_default.store_id = 0
108
                    AND url_key_default.row_id = t0.row_id
109
          LEFT JOIN catalog_category_entity_varchar AS url_path_store
110
                 ON url_path_store.attribute_id = (
111
                        SELECT attribute_id FROM eav_attribute
112
                        WHERE attribute_code = \'url_path\' AND entity_type_id = 3
113
                    )
114
                    AND url_path_store.store_id = :store_id
115
                    AND url_path_store.row_id = t0.row_id
116
          LEFT JOIN catalog_category_entity_varchar AS url_path_default
117
                 ON url_path_default.attribute_id = (
118
                        SELECT attribute_id FROM eav_attribute
119
                        WHERE attribute_code = \'url_path\' AND entity_type_id = 3
120
                    )
121
                    AND url_path_default.store_id = 0
122
                    AND url_path_default.row_id = t0.row_id
123
          LEFT JOIN catalog_category_entity_int AS is_anchor_store
124
                 ON is_anchor_store.attribute_id = (
125
                        SELECT attribute_id FROM eav_attribute
126
                        WHERE attribute_code = \'is_anchor\' AND entity_type_id = 3
127
                    )
128
                    AND is_anchor_store.store_id = :store_id
129
                    AND is_anchor_store.row_id = t0.row_id
130
          LEFT JOIN catalog_category_entity_int AS is_anchor_default
131
                 ON is_anchor_default.attribute_id = (
132
                        SELECT attribute_id FROM eav_attribute
133
                        WHERE attribute_code = \'is_anchor\' AND entity_type_id = 3
134
                    )
135
                    AND is_anchor_default.store_id = 0
136
                    AND is_anchor_default.row_id = t0.row_id',
137
        SqlStatementKeys::CATEGORY_VARCHARS_BY_ENTITY_IDS =>
138
            'SELECT t1.*
139
               FROM catalog_category_entity AS t0
140
         INNER JOIN catalog_category_entity_varchar AS t1
141
                 ON t1.row_id = t0.row_id
142
         INNER JOIN eav_attribute AS t2
143
                 ON t2.entity_type_id = 3
144
                AND t2.attribute_code = \'name\'
145
                AND t1.attribute_id = t2.attribute_id
146
                AND t1.store_id = 0
147
                AND t0.entity_id IN (?)'
148
    );
149
150
    /**
151
     * Initialize the the SQL statements.
152
     */
153
    public function __construct()
154
    {
155
156
        // call the parent constructor
157
        parent::__construct();
158
159
        // merge the class statements
160
        foreach ($this->statements as $key => $statement) {
161
            $this->preparedStatements[$key] = $statement;
162
        }
163
    }
164
}
165