1 | <?php |
||
34 | class CatalogAttributeUpdateObserver extends CatalogAttributeObserver |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * Initialize the attribute with the passed attributes and returns an instance. |
||
39 | * |
||
40 | * @param array $attr The attribute attributes |
||
41 | * |
||
42 | * @return array The initialized attribute |
||
43 | */ |
||
44 | 2 | protected function initializeAttribute(array $attr) |
|
45 | { |
||
46 | |||
47 | // try to load the EAV catalog attribute with the attribute code |
||
48 | 2 | if ($attribute = $this->loadCatalogAttribute($attr[MemberNames::ATTRIBUTE_ID])) { |
|
49 | // unserialize the additional data value if available |
||
50 | 2 | if (is_array($attribute[MemberNames::ADDITIONAL_DATA]) && $attribute[MemberNames::ADDITIONAL_DATA] !== null) { |
|
51 | // merge the additional data if available |
||
52 | $attribute[MemberNames::ADDITIONAL_DATA] = array_merge( |
||
53 | $attr[MemberNames::ADDITIONAL_DATA], |
||
54 | unserialize($attribute[MemberNames::ADDITIONAL_DATA]) |
||
55 | ); |
||
56 | |||
57 | 2 | } elseif (!is_array($attribute[MemberNames::ADDITIONAL_DATA]) && $attribute[MemberNames::ADDITIONAL_DATA] !== null) { |
|
58 | // unserialize and override the additional data |
||
59 | 2 | $attribute[MemberNames::ADDITIONAL_DATA] = unserialize($attribute[MemberNames::ADDITIONAL_DATA]); |
|
60 | 2 | } else { |
|
|
|||
61 | // nothing here |
||
62 | } |
||
63 | |||
64 | // merge the attributes into the entity |
||
65 | 2 | return $this->serializeAdditionalData($this->mergeEntity($attribute, $attr)); |
|
66 | } |
||
67 | |||
68 | // serialize the additional data and return the attributes |
||
69 | return parent::initializeAttribute($attr); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Load's and return's the EAV catalog attribute with the passed attribute ID. |
||
74 | * |
||
75 | * @param string $attributeId The ID of the EAV catalog attribute to load |
||
76 | * |
||
77 | * @return array The EAV catalog attribute |
||
78 | */ |
||
79 | 2 | protected function loadCatalogAttribute($attributeId) |
|
83 | } |
||
84 |
This check looks for the
else
branches ofif
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
else
branches can be removed.could be turned into
This is much more concise to read.