Skip to content

Commit

Permalink
added: price_collection imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijzer committed Jul 5, 2024
1 parent 59d1864 commit 2995aee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Component/Common/Functions/ArrayFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function flatten(array $array, string $separator = '.', string $pr
$result[rtrim($prefix, $separator)][$key] = $value;
}

if (is_array($value) && !empty($value)) {
if (is_array($value) && $value !== []) {
$result += static::flatten($value, $separator, $prefix . $key . $separator, [], $preserveIntKeys);
continue;
}
Expand Down
21 changes: 20 additions & 1 deletion src/Component/Converter/AkeneoFlatProductToCsvConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ public function getAkeneoDataStructure(string $attributeCode, $value, array $con
$value = [$value];
}
break;
case AkeneoHeaderTypes::PRICE:
$amount = null;
$unit = $this->getOption('default_currency');
if (is_numeric($value)) {
$amount = $this->numberize($value);
}
if (is_array($value)) {
if (array_key_exists('amount', $value)) {
$amount = $value['amount'];
}
if (array_key_exists('currency', $value)) {
$unit = $value['currency'];
}
}

$value = [[
'amount' => $amount,
'currency' => $unit,
]];
break;
case AkeneoHeaderTypes::METRIC:
$amount = null;
$unit = $this->getOption('default_metrics:list')[$attributeCode] ?? null;
Expand All @@ -155,7 +175,6 @@ public function getAkeneoDataStructure(string $attributeCode, $value, array $con
}
break;
case AkeneoHeaderTypes::REFDATA_SELECT:
case AkeneoHeaderTypes::PRICE:
// no changes
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Misery\Component\Modifier\NullifyEmptyStringModifier;
use Misery\Component\Reader\ItemCollection;

class DistilledLoadCollectionConverter implements InitConverterInterface, ConverterInterface, ItemCollectionLoaderInterface, RegisteredByNameInterface, OptionsInterface
class ReadLoopItemCollectionConverter implements InitConverterInterface, ConverterInterface, ItemCollectionLoaderInterface, RegisteredByNameInterface, OptionsInterface
{
use OptionsTrait;

Expand Down Expand Up @@ -93,11 +93,11 @@ public function convert(array $item): array

public function getName(): string
{
return 'distill/loop/items';
return 'read/loop/items';
}

public function revert(array $item): array
{
throw new \Exception(DistilledLoadCollectionConverter::class . ' is not revert-able.');
throw new \Exception(ReadLoopItemCollectionConverter::class . ' is not revert-able.');
}
}
2 changes: 1 addition & 1 deletion src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
new Misery\Component\Converter\Akeneo\Api\FamilyVariant(),
new Misery\Component\Converter\Akeneo\Csv\ReferenceEntities(),
new Misery\Component\Converter\Akeneo\Csv\AkeneoProductCreator(),
new Misery\Component\Converter\DistilledLoadCollectionConverter(),
new Misery\Component\Converter\ReadLoopItemCollectionConverter(),
);

$feedRegistry = new Misery\Component\Common\Registry\Registry('feed');
Expand Down

0 comments on commit 2995aee

Please sign in to comment.