@@ 35-75 (lines=41) @@ | ||
32 | * @link https://github.com/techdivision/import-attribute |
|
33 | * @link http://www.techdivision.com |
|
34 | */ |
|
35 | class AttributeOptionUpdateObserver extends AttributeOptionObserver |
|
36 | { |
|
37 | ||
38 | /** |
|
39 | * Initialize the EAV attribute option with the passed attributes and returns an instance. |
|
40 | * |
|
41 | * @param array $attr The EAV attribute option attributes |
|
42 | * |
|
43 | * @return array The initialized EAV attribute option |
|
44 | */ |
|
45 | protected function initializeAttribute(array $attr) |
|
46 | { |
|
47 | ||
48 | // initialize the data to load the EAV attribute option |
|
49 | $value = $this->getValue(ColumnKeys::VALUE); |
|
50 | $storeId = $this->getRowStoreId(StoreViewCodes::ADMIN); |
|
51 | $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE); |
|
52 | ||
53 | // try to load the EAV attribute option |
|
54 | if ($attributeOption = $this->loadAttributeOptionByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)) { |
|
55 | return $this->mergeEntity($attributeOption, $attr); |
|
56 | } |
|
57 | ||
58 | // simply return the attributes |
|
59 | return $attr; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Load's and return's the EAV attribute option with the passed code, store ID and value. |
|
64 | * |
|
65 | * @param string $attributeCode The code of the EAV attribute option to load |
|
66 | * @param integer $storeId The store ID of the attribute option to load |
|
67 | * @param string $value The value of the attribute option to load |
|
68 | * |
|
69 | * @return array The EAV attribute option |
|
70 | */ |
|
71 | protected function loadAttributeOptionByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value) |
|
72 | { |
|
73 | return $this->getAttributeBunchProcessor()->loadAttributeOptionByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value); |
|
74 | } |
|
75 | } |
|
76 |
@@ 35-75 (lines=41) @@ | ||
32 | * @link https://github.com/techdivision/import-attribute |
|
33 | * @link http://www.techdivision.com |
|
34 | */ |
|
35 | class AttributeOptionValueUpdateObserver extends AttributeOptionValueObserver |
|
36 | { |
|
37 | ||
38 | /** |
|
39 | * Initialize the EAV attribute option value with the passed attributes and returns an instance. |
|
40 | * |
|
41 | * @param array $attr The EAV attribute option value attributes |
|
42 | * |
|
43 | * @return array The initialized EAV attribute option value |
|
44 | */ |
|
45 | protected function initializeAttribute(array $attr) |
|
46 | { |
|
47 | ||
48 | // initialize the data to load the EAV attribute option |
|
49 | $value = $this->getValue(ColumnKeys::VALUE); |
|
50 | $storeId = $this->getRowStoreId(StoreViewCodes::ADMIN); |
|
51 | $attributeCode = $this->getValue(ColumnKeys::ATTRIBUTE_CODE); |
|
52 | ||
53 | // try to load the EAV attribute option value |
|
54 | if ($attributeOptionValue = $this->loadAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value)) { |
|
55 | return $this->mergeEntity($attributeOptionValue, $attr); |
|
56 | } |
|
57 | ||
58 | // simply return the attributes |
|
59 | return $attr; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Load's and return's the EAV attribute option value with the passed code, store ID and value. |
|
64 | * |
|
65 | * @param string $attributeCode The code of the EAV attribute option to load |
|
66 | * @param integer $storeId The store ID of the attribute option to load |
|
67 | * @param string $value The value of the attribute option to load |
|
68 | * |
|
69 | * @return array The EAV attribute option value |
|
70 | */ |
|
71 | protected function loadAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value) |
|
72 | { |
|
73 | return $this->getAttributeBunchProcessor()->loadAttributeOptionValueByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value); |
|
74 | } |
|
75 | } |
|
76 |