ePages 6.11.0 - DE_EPAGES/Product/API/CSV/ProductTypeImportHandler.pm

Package DE_EPAGES::Product::API::CSV::ProductTypeImportHandler

This module implements a handler to import producttypes

Base
DE_EPAGES::ShopCSVExportImport::API::CSV::ShopObjectImportHandler
Example
use DE_EPAGES::Product::API::CSV::ProductTypeImportHandler;
DE_EPAGES::Product::API::CSV::ProductTypeImportHandler->importCSV($FileName, $hFileFormat, $Shop);

Functions

analyzeAttributeLine
baseAttributeClassAlias
importObject
importSpecialData
modifyUsedAttributes
testHeaderColumn
testMissingFields

analyzeAttributeLine

Analyzes the current line in the CSV file and fills the object data hash with information for the actual import. Uses $self->topID('Item') as input, which contains the list of values in the current line.

Syntax
my $hAttributeValues = $self->analyzeAttributeLine();
Return
$hAttributeValues (ref.hash)
properties of a object of CSV file with following keys
  • DirectAttributes - direct attributes of the object with following keys
    • Alias - alias of the object - string
    • Class - class object of the object - object
    • Parent - parent object of the object - object
    • more direct attributes which should set via $Object->set method,
      or can used by $Class->insert($hAttributeValues->{'DirectAttributes'});
    - ref.hash
  • DoNotImport - 0 or 1, set to 1 if there are errors to set the parsed values - boolean
  • Object - object if it is found or undef if it doesn't exist - object
  • LocalizedAttributes -localized attributes hash with language id as key - ref.hash
  • Design - attributes hash with template information - ref.hash
  • ProductAttribute - hash with attributes for productattribute - ref.hash
    • DirectAttributes - direct attributes of the object - ref.hash
    • LocalizedAttributes -localized attributes hash with language id as key - ref.hash
    • PreDefAttribute - hash with predef attribute for productattribute
      • DirectAttributes - direct attributes of the object - ref.hash
      • LocalizedAttributes -localized attributes hash with language id as key - ref.hash



baseAttributeClassAlias

return Base AttributeClass Alias, here : 'ProductType'

Syntax
$self->baseAttributeClassAlias();
Return
$BaseAttributeClassAlias (string)
attribute class alias of normal attributes

importObject

calls $hAttributeValues = $self->analyzeAttributeLine, return if (not defined $hAttributeValues or $hAttributeValues->{'DoNotImport'}) if the object exists, it should be at $hAttributeValues->{'Object'} then a $Object->set($hAttributeValues->{'DirectAttributes'}) is called else $Class must exists $hAttributeValues->{'DirectAttributes'}{'Class'} then calls $Class->insertObject($hAttributeValues->{'DirectAttributes'}); then calls foreach language id keys %{ $hAttributeValues->{'LocalizedAttributes'}} : my $hInfo = $hAttributeValues->{'LocalizedAttributes'}{$LanguageID}; $Object->set($hInfo, $LanguageID); calls function $self->importSpecialData($Object, $hAttributeValues); to give the possibility to save more data

Syntax
$self->importObject;

importSpecialData

possibility to import special object data, called by importObject saves template design

Syntax
$self->importSpecialData($Object, $hAttributeValues);
Input
$Object (object)
object which is imported
$hAttributeValues (ref.hash)
attribute values

modifyUsedAttributes

add keys: $hUsedAttributes->{$ColumnIndex}{'IsAliasColumn'} = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Alias' ? 1 : 0; $hUsedAttributes->{'AliasColumn'} with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsAliasColumn'}; $hUsedAttributes->{$ColumnIndex}{'IsProductAttributeAliasColumn'} = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Alias' ? 1 : 0; $hUsedAttributes->{'AliasProductAttributeColumn'} with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsProductAttributeAliasColumn'}; $hUsedAttributes->{$ColumnIndex}{'IsPreDefAttributeAliasColumn'} = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Alias' ? 1 : 0; $hUsedAttributes->{'AliasPreDefAttributeColumn'} with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsPreDefAttributeAliasColumn'}; $hUsedAttributes->{$ColumnIndex}{'IsProductAttributeTypeColumn'} = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Type' ? 1 : 0; $hUsedAttributes->{'TypeProductAttributeColumn'} with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsProductAttributeTypeColumn'};

Syntax
$self->modifyUsedAttributes($hUsedAttributes, $ColumnIndex);
Input
$hUsedAttributes (ref.hash)
used attributes
$ColumnIndex (integer)
current column

testHeaderColumn

possibility to test $hHeader, called by getUsedAttribute only dummy function here

Syntax
$self->testHeaderColumn($hAttribute, $hHeader, $ColumnIndex);
Input
$hAttribute (ref.hash)
used attribute
$hHeader (ref.hash)
current header info
$ColumnIndex (integer)
current column

testMissingFields

throws error 'MISSING_FIELD', if field Alias is missing

Syntax
$self->testMissingFields($hUsedAttributes);
Input
$hUsedAttributes (ref.hash)
used attributes