Completed
Push — master ( 026565...0d4eb6 )
by Tim
13s
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\Ee\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-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Ee\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-ee
30
 * @link      http://www.techdivision.com
31
 */
32
class SqlStatements extends \TechDivision\Import\Utils\SqlStatements
33
{
34
35
    /**
36
     * The SQL statement to load all available categories.
37
     *
38
     * @var string
39
     */
40
    const CATEGORIES = 'categories';
41
42
    /**
43
     * The SQL statement to load the category varchars for a list of entity IDs.
44
     *
45
     * @var string
46
     */
47
    const CATEGORY_VARCHARS_BY_ENTITY_IDS = 'category_varchars.by.entity_ids';
48
49
    /**
50
     * The SQL statements.
51
     *
52
     * @var array
53
     */
54
    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...
55
        SqlStatements::CATEGORIES =>
56
            'SELECT t0.*,
57
                    (SELECT `value`
58
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
59
                      WHERE t1.attribute_code = \'name\'
60
                        AND t1.entity_type_id = 3
61
                        AND t2.attribute_id = t1.attribute_id
62
                        AND t2.store_id = 0
63
                        AND t2.row_id = t0.row_id) AS name,
64
                    (SELECT `value`
65
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
66
                      WHERE t1.attribute_code = \'url_key\'
67
                        AND t1.entity_type_id = 3
68
                        AND t2.attribute_id = t1.attribute_id
69
                        AND t2.store_id = 0
70
                        AND t2.row_id = t0.row_id) AS url_key,
71
                    (SELECT `value`
72
                       FROM eav_attribute t1, catalog_category_entity_varchar t2
73
                      WHERE t1.attribute_code = \'url_path\'
74
                        AND t1.entity_type_id = 3
75
                        AND t2.attribute_id = t1.attribute_id
76
                        AND t2.store_id = 0
77
                        AND t2.row_id = t0.row_id) AS url_path
78
               FROM catalog_category_entity AS t0',
79
        SqlStatements::CATEGORY_VARCHARS_BY_ENTITY_IDS =>
80
            'SELECT t1.*
81
               FROM catalog_category_entity AS t0
82
         INNER JOIN catalog_category_entity_varchar AS t1
83
                 ON t1.row_id = t0.row_id
84
         INNER JOIN eav_attribute AS t2
85
                 ON t2.entity_type_id = 3
86
                AND t2.attribute_code = \'name\'
87
                AND t1.attribute_id = t2.attribute_id
88
                AND t1.store_id = 0
89
                AND t0.entity_id IN (?)'
90
    );
91
92
    /**
93
     * Initialize the the SQL statements.
94
     */
95
    public function __construct()
96
    {
97
98
        // call the parent constructor
99
        parent::__construct();
100
101
        // merge the class statements
102
        foreach ($this->statements as $key => $statement) {
103
            $this->preparedStatements[$key] = $statement;
104
        }
105
    }
106
}
107