Skip to content

Commit

Permalink
added: configurable Fetcher options
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijzer committed Nov 22, 2023
1 parent cffa29e commit 2f82ffe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Component/Converter/Akeneo/Csv/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ public function revert(array $item): array
if (isset($item['enabled'])) {
$output['enabled'] = $item['enabled'];
}
if (array_key_exists($item['family'])) {
if (array_key_exists('family', $item)) {
$output['family'] = $item['family'];
}
if (array_key_exists($item['categories'])) {
if (array_key_exists('categories', $item)) {
$output['categories'] = $item['categories'];
}
if (array_key_exists($item['parent'])) {
if (array_key_exists('parent', $item)) {
$output['parent'] = $item['parent'];
}
$output = $this->decoder->decode($output);
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Item/ItemsFactoryIntoItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function spreadFromConfig(
return [];
}

$result = array_fill_keys($configuration['list'], '');
$result = !empty($configuration['list']) ? array_fill_keys($configuration['list'], '') : [];
$spreadConfiguration = $configuration['spread'];
$attributesToKeep = [];

Expand Down
9 changes: 7 additions & 2 deletions src/Component/Parser/ItemParserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ public function createFromConfiguration(
'type must be filled in.'
)->notEmpty()->string()->inArray(['xml', 'csv', 'xlsx', 'list', 'feed', 'yaml', 'buffer', 'json']);

$fetchers = [
'continuous' => ContinuousBufferFetcher::class,
'zone' => OldCachedZoneFetcher::class
];
$classFetcher = $fetchers[strtolower($configuration['fetcher'] ?? 'zone')];

if (isset($configuration['join'])) {
$joins = $configuration['join'];
unset($configuration['join']);
$mainParser = $this->createFromConfiguration($configuration, $manager);

foreach ($joins as $join) {
$fetcher = clone new OldCachedZoneFetcher($this->createFromConfiguration($join, $manager), $join['link_join'], $join['allow_fileindex_removal'] ?? false);
##$fetcher = clone new ContinuousBufferFetcher($this->createFromConfiguration($join, $manager), $join['link_join'], $join['allow_fileindex_removal'] ?? false);
$fetcher = clone new $classFetcher($this->createFromConfiguration($join, $manager), $join['link_join'], $join['allow_fileindex_removal'] ?? false);
$mainParser = new FunctionalCursor($mainParser, function ($row) use ($fetcher, $join) {
$masterID = $row[$join['link']];
$item = $fetcher->get($masterID) ?? [];
Expand Down
3 changes: 2 additions & 1 deletion src/Component/Parser/XlsxParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ private function init(): void

public function current(): mixed
{
if ($this->cursor === null) {
if (false === $this->cursor->valid()) {
return false;
}

$current = $this->cursor->current();
Expand Down

0 comments on commit 2f82ffe

Please sign in to comment.