Skip to content

Commit

Permalink
More configurable options and small bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
damsfx committed Dec 22, 2021
1 parent e919ef8 commit c5b467c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ return [
'dateFormat' => '_Y-m-d-z', // How to format appended date, default '_Y-m-d'
],

'useCurrencySymbol' => true, // Use currency symbol or code, default true
'useCurrencySymbol' => true, // Use currency symbol (true), code (false), or nothing (null), default true
'removeDiacritics' => false, // Remove diactritcis chars in additional prices column labels, default false
];
```
Expand Down
12 changes: 10 additions & 2 deletions classes/registration/BootControllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ protected function extendMallProduct()
$currentLocale
);

// Init currency symbol
$currencySymbol = '';
if ($this->useCurrencySymbol === true) {
$currencySymbol = $currency->symbol;
} elseif ($this->useCurrencySymbol === false) {
$currencySymbol = $currency->code;
}

// Implement behavior if not already implemented
if (!$controller->isClassExtendedWith('Backend.Behaviors.ImportExportController')) {
$controller->implement[] = 'Backend.Behaviors.ImportExportController';
Expand All @@ -85,9 +93,9 @@ protected function extendMallProduct()
$currencies->each(function (Currency $currency) use (
$importList,
$exportList,
$priceTrad
$priceTrad,
$currencySymbol
) {
$currencySymbol = $this->useCurrencySymbol ? $currency->symbol : $currency->code;
$label = $this->removeDiacritics(sprintf('%s %s', $priceTrad, $currencySymbol));

$importList->columns['price__' . $currency->code] = [
Expand Down
11 changes: 10 additions & 1 deletion models/ProductImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public function importData($results, $sessionKey = null)
$product = Product::where('user_defined_id', $ref)->first();
}

$data['published'] = $data['published'] == 1 ? true: false;
// Test for published status
$published = isset($data['published']) ? $data['published'] : null;
if ($published !== null) {
if ($published == '1') {
$published = true;
} else {
$published = false;
}
$data['published'] = $published;
}

if ($product) {
$product->fill($data);
Expand Down
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
1.0.2: Allow import/export config to be extendable with events
1.0.3: Add options to export public and backend links to products
1.0.4: Add options to fine tune column names and to avoid some characters encoding errors in export/import files
1.0.5: More configurable options and small bugfix

0 comments on commit c5b467c

Please sign in to comment.