Completed
Push — master ( 994c5c...018398 )
by Tim
10s
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 97
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 97
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\UrlRewrite\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-url-rewrite
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\UrlRewrite\Repositories;
22
23
use TechDivision\Import\Product\UrlRewrite\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-url-rewrite
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::CREATE_URL_REWRITE =>
44
            'INSERT
45
               INTO url_rewrite
46
                    (entity_type,
47
                     entity_id,
48
                     request_path,
49
                     target_path,
50
                     redirect_type,
51
                     store_id,
52
                     description,
53
                     is_autogenerated,
54
                     metadata)
55
            VALUES (:entity_type,
56
                    :entity_id,
57
                    :request_path,
58
                    :target_path,
59
                    :redirect_type,
60
                    :store_id,
61
                    :description,
62
                    :is_autogenerated,
63
                    :metadata)',
64
        SqlStatementKeys::UPDATE_URL_REWRITE =>
65
            'UPDATE url_rewrite
66
                SET entity_type = :entity_type,
67
                    entity_id = :entity_id,
68
                    request_path = :request_path,
69
                    target_path = :target_path,
70
                    redirect_type = :redirect_type,
71
                    store_id = :store_id,
72
                    description = :description,
73
                    is_autogenerated = :is_autogenerated,
74
                    metadata = :metadata
75
              WHERE url_rewrite_id = :url_rewrite_id',
76
        SqlStatementKeys::CREATE_URL_REWRITE_PRODUCT_CATEGORY =>
77
            'INSERT
78
               INTO catalog_url_rewrite_product_category
79
                    (url_rewrite_id,
80
                     category_id,
81
                     product_id)
82
             VALUES (:url_rewrite_id,
83
                     :category_id,
84
                     :product_id)',
85
        SqlStatementKeys::UPDATE_URL_REWRITE_PRODUCT_CATEGORY =>
86
            'UPDATE catalog_url_rewrite_product_category
87
                SET category_id = :category_id,
88
                    product_id = :product_id
89
              WHERE url_rewrite_id = :url_rewrite_id',
90
        SqlStatementKeys::DELETE_URL_REWRITE_PRODUCT_CATEGORY =>
91
            'DELETE
92
               FROM catalog_url_rewrite_product_category
93
              WHERE url_rewrite_id = :url_rewrite_id',
94
        SqlStatementKeys::URL_REWRITE_PRODUCT_CATEGORY =>
95
            'SELECT *
96
               FROM catalog_url_rewrite_product_category
97
              WHERE url_rewrite_id = :url_rewrite_id',
98
        SqlStatementKeys::URL_REWRITES_BY_SKU =>
99
            'SELECT t2.*
100
               FROM catalog_product_entity t1,
101
                    url_rewrite t2
102
              WHERE t1.sku = :sku
103
                AND t2.entity_id = t1.entity_id
104
                AND t2.entity_type = \'product\'',
105
        SqlStatementKeys::URL_REWRITE_PRODUCT_CATEGORIES_BY_SKU =>
106
            'SELECT t3.*
107
               FROM catalog_product_entity t1,
108
                    url_rewrite t2,
109
                    catalog_url_rewrite_product_category t3
110
              WHERE t1.sku = :sku
111
                AND t2.entity_id = t1.entity_id
112
                AND t2.entity_type = \'product\'
113
                AND t3.url_rewrite_id = t2.url_rewrite_id'
114
    );
115
116
    /**
117
     * Initialize the the SQL statements.
118
     */
119
    public function __construct()
120
    {
121
122
        // call the parent constructor
123
        parent::__construct();
124
125
        // merge the class statements
126
        foreach ($this->statements as $key => $statement) {
127
            $this->preparedStatements[$key] = $statement;
128
        }
129
    }
130
}
131