Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/Observers/ProductSourceItemObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down