Completed
Push — master ( 693701...15b237 )
by Tim
9s
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Variant\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-variant
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Variant\Repositories;
22
23
use TechDivision\Import\Product\Variant\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-variant
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_RELATION =>
44
            'SELECT *
45
               FROM catalog_product_relation
46
              WHERE parent_id = :parent_id
47
                AND child_id = :child_id',
48
        SqlStatementKeys::PRODUCT_SUPER_LINK =>
49
            'SELECT *
50
               FROM catalog_product_super_link
51
              WHERE product_id = :product_id
52
                AND parent_id = :parent_id',
53
        SqlStatementKeys::PRODUCT_SUPER_ATTRIBUTE =>
54
            'SELECT *
55
               FROM catalog_product_super_attribute
56
              WHERE product_id = :product_id
57
                AND attribute_id = :attribute_id',
58
        SqlStatementKeys::PRODUCT_SUPER_ATTRIBUTE_LABEL =>
59
            'SELECT *
60
               FROM catalog_product_super_attribute_label
61
              WHERE product_super_attribute_id = :product_super_attribute_id
62
                AND store_id = :store_id',
63
        SqlStatementKeys::CREATE_PRODUCT_RELATION =>
64
            'INSERT
65
               INTO catalog_product_relation
66
                    (parent_id,
67
                     child_id)
68
             VALUES (:parent_id,
69
                     :child_id)',
70
        SqlStatementKeys::CREATE_PRODUCT_SUPER_LINK =>
71
            'INSERT
72
               INTO catalog_product_super_link
73
                    (product_id,
74
                     parent_id)
75
             VALUES (:product_id,
76
                     :parent_id)',
77
        SqlStatementKeys::CREATE_PRODUCT_SUPER_ATTRIBUTE =>
78
            'INSERT
79
               INTO catalog_product_super_attribute
80
                    (product_id,
81
                     attribute_id,
82
                     position)
83
             VALUES (:product_id,
84
                     :attribute_id,
85
                     :position)',
86
        SqlStatementKeys::UPDATE_PRODUCT_SUPER_ATTRIBUTE =>
87
            'UPDATE catalog_product_super_attribute
88
                SET product_id = :product_id,
89
                    attribute_id = :attribute_id,
90
                    position = :position
91
              WHERE product_super_attribute_id = :product_super_attribute_id',
92
        SqlStatementKeys::CREATE_PRODUCT_SUPER_ATTRIBUTE_LABEL =>
93
            'INSERT
94
                INTO catalog_product_super_attribute_label
95
                     (product_super_attribute_id,
96
                      store_id,
97
                      use_default,
98
                      value)
99
              VALUES (:product_super_attribute_id,
100
                      :store_id,
101
                      :use_default,
102
                      :value)',
103
        SqlStatementKeys::UPDATE_PRODUCT_SUPER_ATTRIBUTE_LABEL =>
104
            'UPDATE catalog_product_super_attribute_label
105
                SET product_super_attribute_id = :product_super_attribute_id,
106
                    store_id = :store_id,
107
                    use_default = :use_default,
108
                    value = :value
109
              WHERE value_id = :value_id'
110
    );
111
112
    /**
113
     * Initialize the the SQL statements.
114
     */
115
    public function __construct()
116
    {
117
118
        // call the parent constructor
119
        parent::__construct();
120
121
        // merge the class statements
122
        foreach ($this->statements as $key => $statement) {
123
            $this->preparedStatements[$key] = $statement;
124
        }
125
    }
126
}
127