Completed
Pull Request — master (#5)
by Tim
02:51
created

loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Ee\Observers\EeProductAttributeUpdateObserver
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-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Ee\Observers;
22
23
use TechDivision\Import\Product\Ee\Utils\MemberNames;
24
use TechDivision\Import\Product\Observers\ProductAttributeUpdateObserver;
25
26
/**
27
 * Observer that provides product attribute update functionality.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2016 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import-product-ee
33
 * @link      http://www.techdivision.com
34
 */
35
class EeProductAttributeUpdateObserver extends ProductAttributeUpdateObserver
36
{
37
38
    /**
39
     * The trait providing basic EE product attribute functionality.
40
     *
41
     * @var \TechDivision\Import\Product\Ee\Observers\EeProductAttributeObserverTrait
42
     */
43
    use EeProductAttributeObserverTrait;
44
45
    /**
46
     * Initialize the category product with the passed attributes and returns an instance.
47
     *
48
     * @param array $attr The category product attributes
49
     *
50
     * @return array The initialized category product
51
     */
52
    public function initializeAttribute(array $attr)
53
    {
54
55
        // load the supported backend types
56
        $backendTypes = $this->getBackendTypes();
57
58
        // initialize the persist method for the found backend type
59
        list (, $loadMethod) = $backendTypes[$this->getBackendType()];
60
61
        // load row/store/attribute ID
62
        $rowId = $attr[MemberNames::ROW_ID];
63
        $storeId = $attr[MemberNames::STORE_ID];
64
        $attributeId = $attr[MemberNames::ATTRIBUTE_ID];
65
66
        // try to load the attribute with the passed row/attribute/store ID
67
        // and merge it with the attributes
68
        if ($entity = $this->$loadMethod($rowId, $attributeId, $storeId)) {
69
            return $this->mergeEntity($entity, $attr);
70
        }
71
72
        // otherwise simply return the attributes
73
        return $attr;
74
    }
75
76
    /**
77
     * Load's and return's the datetime attribute with the passed row/attribute/store ID.
78
     *
79
     * @param integer $rowId       The row ID of the attribute
80
     * @param integer $attributeId The attribute ID of the attribute
81
     * @param integer $storeId     The store ID of the attribute
82
     *
83
     * @return array|null The datetime attribute
84
     */
85
    public function loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId)
86
    {
87
        return  $this->getSubject()->loadProductDatetimeAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId);
88
    }
89
90
    /**
91
     * Load's and return's the decimal attribute with the passed row/attribute/store ID.
92
     *
93
     * @param integer $rowId       The row ID of the attribute
94
     * @param integer $attributeId The attribute ID of the attribute
95
     * @param integer $storeId     The store ID of the attribute
96
     *
97
     * @return array|null The decimal attribute
98
     */
99
    public function loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId)
100
    {
101
        return  $this->getSubject()->loadProductDecimalAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId);
102
    }
103
104
    /**
105
     * Load's and return's the integer attribute with the passed row/attribute/store ID.
106
     *
107
     * @param integer $rowId       The row ID of the attribute
108
     * @param integer $attributeId The attribute ID of the attribute
109
     * @param integer $storeId     The store ID of the attribute
110
     *
111
     * @return array|null The integer attribute
112
     */
113
    public function loadProductIntAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId)
114
    {
115
        return $this->getSubject()->loadProductIntAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId);
116
    }
117
118
    /**
119
     * Load's and return's the text attribute with the passed row/attribute/store ID.
120
     *
121
     * @param integer $rowId       The row ID of the attribute
122
     * @param integer $attributeId The attribute ID of the attribute
123
     * @param integer $storeId     The store ID of the attribute
124
     *
125
     * @return array|null The text attribute
126
     */
127
    public function loadProductTextAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId)
128
    {
129
        return $this->getSubject()->loadProductTextAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId);
130
    }
131
132
    /**
133
     * Load's and return's the varchar attribute with the passed row/attribute/store ID.
134
     *
135
     * @param integer $rowId       The row ID of the attribute
136
     * @param integer $attributeId The attribute ID of the attribute
137
     * @param integer $storeId     The store ID of the attribute
138
     *
139
     * @return array|null The varchar attribute
140
     */
141
    public function loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId)
142
    {
143
        return $this->getSubject()->loadProductVarcharAttributeByRowIdAndAttributeIdAndStoreId($rowId, $attributeId, $storeId);
144
    }
145
}
146