Code Duplication    Length = 30-30 lines in 2 locations

src/Observers/BundleOptionObserver.php 1 location

@@ 136-165 (lines=30) @@
133
     *
134
     * @return array The prepared attributes
135
     */
136
    protected function prepareAttributes()
137
    {
138
139
        // reset the position counter for the bundle selection
140
        $this->resetPositionCounter();
141
142
        try {
143
            // load and map the parent SKU
144
            $parentId = $this->mapSku($this->getValue(ColumnKeys::BUNDLE_PARENT_SKU));
145
        } catch (\Exception $e) {
146
            throw $this->wrapException(array(ColumnKeys::BUNDLE_PARENT_SKU), $e);
147
        }
148
149
        // extract the parent/child ID as well as type and position
150
        $required = $this->getValue(ColumnKeys::BUNDLE_VALUE_REQUIRED);
151
        $type = $this->getValue(ColumnKeys::BUNDLE_VALUE_TYPE);
152
        $position = 1;
153
154
        // return the prepared product
155
        return $this->initializeEntity(
156
            $this->loadRawEntity(
157
                array(
158
                    MemberNames::PARENT_ID => $parentId,
159
                    MemberNames::REQUIRED  => $required,
160
                    MemberNames::POSITION  => $position,
161
                    MemberNames::TYPE      => $type
162
                )
163
            )
164
        );
165
    }
166
167
    /**
168
     * Load's and return's a raw entity without primary key but the mandatory members only and nulled values.

src/Observers/BundleOptionValueObserver.php 1 location

@@ 112-141 (lines=30) @@
109
     *
110
     * @return array The prepared attributes
111
     */
112
    protected function prepareAttributes()
113
    {
114
115
        // load the product bundle option name
116
        $name = $this->getValue(ColumnKeys::BUNDLE_VALUE_NAME);
117
118
        // load the actual option ID
119
        $optionId = $this->getLastOptionId();
120
121
        try {
122
            // load and map the parent SKU
123
            $parentProductId = $this->mapSku($this->getValue(ColumnKeys::BUNDLE_PARENT_SKU));
124
        } catch (\Exception $e) {
125
            throw $this->wrapException(array(ColumnKeys::BUNDLE_PARENT_SKU), $e);
126
        }
127
128
        // load the store/website ID
129
        $store = $this->getStoreByStoreCode($this->getStoreViewCode(StoreViewCodes::ADMIN));
130
        $storeId = $store[MemberNames::STORE_ID];
131
132
        // return the prepared product
133
        return $this->initializeEntity(
134
            array(
135
                MemberNames::OPTION_ID         => $optionId,
136
                MemberNames::PARENT_PRODUCT_ID => $parentProductId,
137
                MemberNames::STORE_ID          => $storeId,
138
                MemberNames::TITLE             => $name
139
            )
140
        );
141
    }
142
143
    /**
144
     * Initialize the bundle option value with the passed attributes and returns an instance.