| @@ 94-120 (lines=27) @@ | ||
| 91 | * @return void |
|
| 92 | * @throws \Exception Is thrown, if the product with the SKU can not be loaded |
|
| 93 | */ |
|
| 94 | protected function process() |
|
| 95 | { |
|
| 96 | ||
| 97 | // load the SKU from the column |
|
| 98 | $sku = $this->getValue($this->getSkuColumnName()); |
|
| 99 | ||
| 100 | // query whether or not the product has already been processed |
|
| 101 | if ($this->hasBeenProcessed($sku)) { |
|
| 102 | return; |
|
| 103 | } |
|
| 104 | ||
| 105 | // try to load it and map the entity ID of the product with the passed SKU otherwise |
|
| 106 | if ($product = $this->loadProduct($sku)) { |
|
| 107 | $this->addSkuPkMapping($product); |
|
| 108 | } else { |
|
| 109 | // initialize the error message |
|
| 110 | $message = sprintf('Can\'t load product with SKU "%s"', $sku); |
|
| 111 | // load the subject |
|
| 112 | $subject = $this->getSubject(); |
|
| 113 | // query whether or not debug mode has been enabled |
|
| 114 | if ($subject->isDebugMode()) { |
|
| 115 | $subject->getSystemLogger()->warning($subject->appendExceptionSuffix($message)); |
|
| 116 | } else { |
|
| 117 | throw new \Exception($message); |
|
| 118 | } |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * Map the PK for the product with the passed SKU. |
|
| @@ 72-98 (lines=27) @@ | ||
| 69 | * @return array The processed row |
|
| 70 | * @throws \Exception Is thrown, if the product with the SKU can not be loaded |
|
| 71 | */ |
|
| 72 | protected function process() |
|
| 73 | { |
|
| 74 | ||
| 75 | // query whether or not, we've found a new SKU => means we've found a new product |
|
| 76 | if ($this->isLastSku($sku = $this->getValue(ColumnKeys::SKU))) { |
|
| 77 | return; |
|
| 78 | } |
|
| 79 | ||
| 80 | // set the entity ID for the product with the passed SKU |
|
| 81 | if ($product = $this->loadProduct($sku)) { |
|
| 82 | $this->setIds($product); |
|
| 83 | } else { |
|
| 84 | // initialize the error message |
|
| 85 | $message = sprintf('Can\'t load entity ID for product with SKU %s', $sku); |
|
| 86 | // load the subject |
|
| 87 | $subject = $this->getSubject(); |
|
| 88 | // query whether or not debug mode has been enabled |
|
| 89 | if ($subject->isDebugMode()) { |
|
| 90 | // log a warning, that the product with the given SKU can not be loaded |
|
| 91 | $subject->getSystemLogger()->warning($subject->appendExceptionSuffix($message)); |
|
| 92 | // skip processing the actual row |
|
| 93 | $subject->skipRow(); |
|
| 94 | } else { |
|
| 95 | throw new \Exception($message); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * Temporarily persist's the IDs of the passed product. |
|
| @@ 71-94 (lines=24) @@ | ||
| 68 | * @return array The processed row |
|
| 69 | * @throws \Exception Is thrown, if the product with the SKU can not be loaded |
|
| 70 | */ |
|
| 71 | protected function process() |
|
| 72 | { |
|
| 73 | ||
| 74 | // query whether or not, we've found a new SKU => means we've found a new product |
|
| 75 | if ($this->isLastSku($sku = $this->getValue(ColumnKeys::SKU))) { |
|
| 76 | return; |
|
| 77 | } |
|
| 78 | ||
| 79 | // preserve the entity ID for the product with the passed SKU |
|
| 80 | if ($product = $this->loadProduct($sku)) { |
|
| 81 | $this->preLoadEntityId($product); |
|
| 82 | } else { |
|
| 83 | // initialize the error message |
|
| 84 | $message = sprintf('Can\'t pre-load product with SKU %s', $sku); |
|
| 85 | // load the subject |
|
| 86 | $subject = $this->getSubject(); |
|
| 87 | // query whether or not debug mode has been enabled |
|
| 88 | if ($subject->isDebugMode()) { |
|
| 89 | $subject->getSystemLogger()->warning($subject->appendExceptionSuffix($message)); |
|
| 90 | } else { |
|
| 91 | throw new \Exception($message); |
|
| 92 | } |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Pre-load the entity ID for the passed product. |
|