| @@ 203-235 (lines=33) @@ | ||
| 200 | $parentSku = $this->getValue(ColumnKeys::SKU); |
|
| 201 | foreach ($actualVariants as $parentProductId => $childData) { |
|
| 202 | // load the existing variant entities for the product with the given SKU |
|
| 203 | foreach ($this->getProductVariantProcessor() |
|
| 204 | ->loadProductSuperLinksFromParent($parentProductId) as $existingVariantChildren) { |
|
| 205 | if (in_array($existingVariantChildren[MemberNames::PRODUCT_ID], $childData)) { |
|
| 206 | continue; |
|
| 207 | } |
|
| 208 | ||
| 209 | try { |
|
| 210 | // remove the old variantes from the database |
|
| 211 | $this->getProductVariantProcessor() |
|
| 212 | ->deleteProductSuperLink(array(MemberNames::LINK_ID => $existingVariantChildren[MemberNames::LINK_ID])); |
|
| 213 | ||
| 214 | // log a debug message that the image has been removed |
|
| 215 | $this->getSubject() |
|
| 216 | ->getSystemLogger() |
|
| 217 | ->info( |
|
| 218 | $this->getSubject()->appendExceptionSuffix( |
|
| 219 | sprintf( |
|
| 220 | 'Successfully clean up variants for product with SKU "%s"', |
|
| 221 | $parentSku |
|
| 222 | ) |
|
| 223 | ) |
|
| 224 | ); |
|
| 225 | } catch (\Exception $e) { |
|
| 226 | // log a warning if debug mode has been enabled and the file is NOT available |
|
| 227 | if ($this->getSubject()->isDebugMode()) { |
|
| 228 | $this->getSubject() |
|
| 229 | ->getSystemLogger() |
|
| 230 | ->critical($this->getSubject()->appendExceptionSuffix($e->getMessage())); |
|
| 231 | } else { |
|
| 232 | throw $e; |
|
| 233 | } |
|
| 234 | } |
|
| 235 | } |
|
| 236 | } |
|
| 237 | } |
|
| 238 | ||
| @@ 259-291 (lines=33) @@ | ||
| 256 | } |
|
| 257 | } |
|
| 258 | // load the existing super attributes for the product with the given SKU |
|
| 259 | foreach ($this->getProductVariantProcessor() |
|
| 260 | ->loadProductSuperAttributesFromProduct($parentProductId) as $existingSuperAttribute) { |
|
| 261 | if (in_array($existingSuperAttribute[MemberNames::ATTRIBUTE_ID], $attributeFromParentProduct)) { |
|
| 262 | continue; |
|
| 263 | } |
|
| 264 | ||
| 265 | try { |
|
| 266 | // remove the old super attributes from the database |
|
| 267 | $this->getProductVariantProcessor() |
|
| 268 | ->deleteProductSuperAttribute(array(MemberNames::PRODUCT_SUPER_ATTRIBUTE_ID => $existingSuperAttribute[MemberNames::PRODUCT_SUPER_ATTRIBUTE_ID])); |
|
| 269 | ||
| 270 | // log a debug message that the image has been removed |
|
| 271 | $this->getSubject() |
|
| 272 | ->getSystemLogger() |
|
| 273 | ->info( |
|
| 274 | $this->getSubject()->appendExceptionSuffix( |
|
| 275 | sprintf( |
|
| 276 | 'Successfully clean up attributes for product with SKU "%s"', |
|
| 277 | $parentSku |
|
| 278 | ) |
|
| 279 | ) |
|
| 280 | ); |
|
| 281 | } catch (\Exception $e) { |
|
| 282 | // log a warning if debug mode has been enabled and the file is NOT available |
|
| 283 | if ($this->getSubject()->isDebugMode()) { |
|
| 284 | $this->getSubject() |
|
| 285 | ->getSystemLogger() |
|
| 286 | ->critical($this->getSubject()->appendExceptionSuffix($e->getMessage())); |
|
| 287 | } else { |
|
| 288 | throw $e; |
|
| 289 | } |
|
| 290 | } |
|
| 291 | } |
|
| 292 | } |
|
| 293 | } |
|
| 294 | } |
|