Package DE_EPAGES::CSVExportImport::API::CSV::ObjectExportDriver
This module implements a handler to export objects via csv
Base |
DE_EPAGES::Presentation::API::CSV::MonitoredExportDriver |
Example |
use DE_EPAGES::CSVExportImport::API::CSV::ObjectExportDriver; my @Attributes; push @Attributes, { Alias => 'Alias', Type => 'String', HeaderString => 'Alias', }; push @Attributes, { Alias => 'Name', Type => 'String', HeaderString => 'Name (en)', LanguageID => GetPKeyLanguageByCode('en'), }; push @Attributes, { Alias => 'ListPrice', HeaderString => 'ListPrice (EUR)', Type => 'Money' }; my $Exporter = DE_EPAGES::CSVExportImport::API::CSV::ObjectExportDriver->new; my $Shop = LoadObjectByPath( '/Shops/DemoShop' ); $Exporter->exportCSV( 'Products.csv', { LocaleID => 'de_DE' }, \@Attributes, $Shop, $Shop->get('Products') ); |
Functions
- drive
- exportCSV
- exportLine
- formatValue
- getObjectAttributeValue
- getValues
- items
- languages
- locale
- startMonitor
- writeHeader
drive
starts the monitor 'CSVExportMonitor' and starts the export of data via $self->SUPER::drive()
Syntax |
$self->drive(); |
exportCSV
exports object attributes to a CVS file.
Syntax |
$Exporter->exportCSV($FileName, $hFormat, $aColumns, $ViewObject, $aObjects ); |
Input |
|
exportLine
Writes one line to the CSV file. Gets the values of the current export item from the function getValues. Increments the monitor counter if defined $self->monitor.
Syntax |
$self->exportLine(); |
formatValue
Formats $Value according to $Type.
Syntax |
$FormattedValue = $self->formatValue( $Value, $Type ); |
Input |
|
Return |
|
getObjectAttributeValue
Returns the raw value of a single attribute. Use formatValue to get the formatted value.
Syntax |
my $Value = getObjectAttributeValue($Object, $hAttribute); |
Input |
|
Return |
|
getValues
returns the values of the attributes from function columns(), uses function getObjectAttributeValue, formats the value via function DE_EPAGES::CSVExportImport::API::Tools::FormatValue()
Syntax |
my $aValues = $self->getValues; |
Return |
|
items
Returns the objects to export, throws a Warning 'NO_ITEMS' if no items, set Monitor 'Total' if defined $self->monitor
Syntax |
my $Items = $self->items(); |
Return |
|
languages
return the languages for attributes
Syntax |
$ahLanguages = $self->languages; |
Return |
|
locale
return the current Locale
Syntax |
$Locale = $self->locale; |
Return |
|
startMonitor
starts the progress monitor. Creates an object of DE_EPAGES::Presentation::API::Object::ProgressMonitor if run inside the application server, otherwise the package DE_EPAGES::Core::API::Object::ProgressMonitor is used.
Syntax |
$self->startMonitor($PageTypeName); |
Input |
|
writeHeader
Writes the CSV header line using the 'HeaderString' key of the column definition (see exportCSV).
Syntax |
$self->writeHeader(); |