Conditions | 2 |
Paths | 2 |
Total Lines | 68 |
Code Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
87 | protected function prepareAttributes() |
||
88 | { |
||
89 | |||
90 | // load the recently created EAV attribute ID |
||
91 | $attributeId = $this->getLastAttributeId(); |
||
92 | |||
93 | // load the data from the row |
||
94 | $frontendInputRenderer = $this->getValue(ColumnKeys::FRONTEND_INPUT_RENDERER); |
||
95 | $isGlobal = $this->getValue(ColumnKeys::IS_GLOBAL, 1); |
||
96 | $isVisible = $this->getValue(ColumnKeys::IS_VISIBLE, 1); |
||
97 | $isSearchable = $this->getValue(ColumnKeys::IS_SEARCHABLE, 0); |
||
98 | $isFilterable = $this->getValue(ColumnKeys::IS_FILTERABLE, 0); |
||
99 | $isComparable = $this->getValue(ColumnKeys::IS_COMPARABLE, 0); |
||
100 | $isVisibleOnFront = $this->getValue(ColumnKeys::IS_VISIBLE_ON_FRONT, 0); |
||
101 | $isHtmlAllowedOnFront = $this->getValue(ColumnKeys::IS_HTML_ALLOWED_ON_FRONT, 0); |
||
102 | $isUsedForPriceRules = $this->getValue(ColumnKeys::IS_USED_FOR_PRICE_RULES, 0); |
||
103 | $isFilterableInSearch = $this->getValue(ColumnKeys::IS_FILTERABLE_IN_SEARCH, 0); |
||
104 | $usedInProductListing = $this->getValue(ColumnKeys::USED_IN_PRODUCT_LISTING, 0); |
||
105 | $usedForSortBy = $this->getValue(ColumnKeys::USED_FOR_SORT_BY, 0); |
||
106 | $applyTo = $this->getValue(ColumnKeys::APPLY_TO); |
||
107 | $isVisibleInAdvancedSearch = $this->getValue(ColumnKeys::IS_VISIBLE_IN_ADVANCED_SEARCH, 0); |
||
108 | $position = $this->getValue(ColumnKeys::POSITION, 0); |
||
109 | $isWysiwygEnabled = $this->getValue(ColumnKeys::IS_WYSIWYG_ENABLED, 0); |
||
110 | $isUsedForPromoRules = $this->getValue(ColumnKeys::IS_USED_FOR_PROMO_RULES, 0); |
||
111 | $isRequiredInAdminStore = $this->getValue(ColumnKeys::IS_REQUIRED_IN_ADMIN_STORE, 0); |
||
112 | $isUsedInGrid = $this->getValue(ColumnKeys::IS_USED_IN_GRID, 0); |
||
113 | $isVisibleInGrid = $this->getValue(ColumnKeys::IS_VISIBLE_IN_GRID, 0); |
||
114 | $isFilterableInGrid = $this->getValue(ColumnKeys::IS_FILTERABLE_IN_GRID, 0); |
||
115 | $searchWeight = $this->getValue(ColumnKeys::SEARCH_WEIGHT, 1); |
||
116 | |||
117 | // load and extract the additional data |
||
118 | $additionalData = array(); |
||
119 | $explodedAdditionalData = $this->getValue(ColumnKeys::ADDITIONAL_DATA, array(), array($this, 'explode')); |
||
120 | foreach ($explodedAdditionalData as $value) { |
||
121 | list ($key, $val) = $this->explode($value, '='); |
||
122 | $additionalData[$key] = $val; |
||
123 | } |
||
124 | |||
125 | // return the prepared product |
||
126 | return $this->initializeEntity( |
||
127 | array( |
||
128 | MemberNames::ATTRIBUTE_ID => $attributeId, |
||
129 | MemberNames::FRONTEND_INPUT_RENDERER => $frontendInputRenderer, |
||
130 | MemberNames::IS_GLOBAL => $isGlobal, |
||
131 | MemberNames::IS_VISIBLE => $isVisible, |
||
132 | MemberNames::IS_SEARCHABLE => $isSearchable, |
||
133 | MemberNames::IS_FILTERABLE => $isFilterable, |
||
134 | MemberNames::IS_COMPARABLE => $isComparable, |
||
135 | MemberNames::IS_VISIBLE_ON_FRONT => $isVisibleOnFront, |
||
136 | MemberNames::IS_HTML_ALLOWED_ON_FRONT => $isHtmlAllowedOnFront, |
||
137 | MemberNames::IS_USED_FOR_PRICE_RULES => $isUsedForPriceRules, |
||
138 | MemberNames::IS_FILTERABLE_IN_SEARCH => $isFilterableInSearch, |
||
139 | MemberNames::USED_IN_PRODUCT_LISTING => $usedInProductListing, |
||
140 | MemberNames::USED_FOR_SORT_BY => $usedForSortBy, |
||
141 | MemberNames::APPLY_TO => $applyTo, |
||
142 | MemberNames::IS_VISIBLE_IN_ADVANCED_SEARCH => $isVisibleInAdvancedSearch, |
||
143 | MemberNames::POSITION => $position, |
||
144 | MemberNames::IS_WYSIWYG_ENABLED => $isWysiwygEnabled, |
||
145 | MemberNames::IS_USED_FOR_PROMO_RULES => $isUsedForPromoRules, |
||
146 | MemberNames::IS_REQUIRED_IN_ADMIN_STORE => $isRequiredInAdminStore, |
||
147 | MemberNames::IS_USED_IN_GRID => $isUsedInGrid, |
||
148 | MemberNames::IS_VISIBLE_IN_GRID => $isVisibleInGrid, |
||
149 | MemberNames::IS_FILTERABLE_IN_GRID => $isFilterableInGrid, |
||
150 | MemberNames::SEARCH_WEIGHT => $searchWeight, |
||
151 | MemberNames::ADDITIONAL_DATA => $additionalData |
||
152 | ) |
||
153 | ); |
||
154 | } |
||
155 | |||
243 |