diff --git a/src/Observers/ProductSourceItemObserver.php b/src/Observers/ProductSourceItemObserver.php index 0b9bec3..1f73e20 100755 --- a/src/Observers/ProductSourceItemObserver.php +++ b/src/Observers/ProductSourceItemObserver.php @@ -82,20 +82,22 @@ public function createObserver(SubjectInterface $subject) { // load the available inventory sources - $inventorySources = $this->getProcessor()->loadInventorySources(); - - // initialize the template for the inventory source - // column, used if the column is NOT part of the file - foreach ($inventorySources as $inventorySource) { - // initialize the default values - $defaultValue = array( - sprintf('%s=%s', ColumnKeys::SOURCE_CODE, $inventorySource[MemberNames::SOURCE_CODE]), - sprintf('%s=1', ColumnKeys::STATUS), - sprintf('%s=%%d', ColumnKeys::QUANTITY) - ); - // concatenate them with the multiple field delimiter and add them to the array with the templates - $this->templateDefaultValues[] = implode($subject->getMultipleFieldDelimiter(), $defaultValue); - } + try { + $inventorySources = $this->getProcessor()->loadInventorySources(); + + // initialize the template for the inventory source + // column, used if the column is NOT part of the file + foreach ($inventorySources as $inventorySource) { + // initialize the default values + $defaultValue = [ + sprintf('%s=%s', ColumnKeys::SOURCE_CODE, $inventorySource[MemberNames::SOURCE_CODE]), + sprintf('%s=1', ColumnKeys::STATUS), + sprintf('%s=%%d', ColumnKeys::QUANTITY), + ]; + // concatenate them with the multiple field delimiter and add them to the array with the templates + $this->templateDefaultValues[] = implode($subject->getMultipleFieldDelimiter(), $defaultValue); + } + } catch (\Exception $exception) { /* no inventory source available -> just skip */ } // return the instance itself return $this;