Package DE_EPAGES::ShopCSVExportImport::API::CSV::ShopObjectImportHandler
This module implements a handler to import shop objects
Functions
- analyzeHeaderLine
- fixObjectFileAttributes
- importObject
- importSpecialData
- modifyObject
- modifyUsedAttributes
- processImportedImageAttribute
- processMediaGalleryImage
- testHeaderColumn
- testMissingFields
- throwImageMissingWarning
analyzeHeaderLine
Syntax |
my $hUsedAttributes = $self->analyzeHeaderLine();
|
Return |
- $hUsedAttributes (ref.hash of hashes)
- properties of each column of CSV file
- $ColumnIndex | integer | index of column
- Attribute - e.g. Class, Alias, Color
- Class - AttributeClass e.g. Jacket
- Type - Attribute type, e.g. LocalizedString
- IsObject - 0 or 1, set to 1 if Attribute IsObject
- LanguageID - only set if Type =~ /Localized/
- CurrencyID - only set if Type eq 'Price'
- TaxModel - 0 (==net) or 1, only set if Type eq 'Price'
- LocaleID - only set for DATETIME_TYPES, hash, e.g. 'en_US'
|
fixObjectFileAttributes
Removes any paths from the image file name attributes of the given object.
Syntax |
$self->fixObjectFileAttributes($Object, \@AttributeNames);
|
Example |
$self->fixObjectFileAttributes($Product,
['ImageLarge', 'ImageMedium', 'ImageSmall', 'ImageHotDeal']);
|
Input |
- $Object (object)
- Object
- $aAttributes (ref.array)
- Array of the attribute names to fix
|
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
only dummy function here
Syntax |
$self->importSpecialData($Object, $hAttributeValues);
|
Input |
- $Object (object)
- object which is imported
- $hAttributeValues (ref.hash)
- attribute values
|
modifyObject
possibility to modify the object after it's creation or modification by
the csv import. Called by importObject, only dummy function here.
Syntax |
$self->modifyObject($Object, $hOldProductAttributes, $hAttributeValues);
|
Input |
- $Object (object)
- object which is imported
- $hOldProductAttributes (ref.hash)
- attributes of the object before the import
- $hDirectAttributes (ref.hash)
- direct attribute values
|
modifyUsedAttributes
add keys to $hUsedAttributes->{$ColumnIndex}
IsClassColumn = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Class' ? 1: 0
IsAliasColumn = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Alias' ? 1: 0
IsParentColumn = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'Parent' ? 1: 0
add keys to hUsedAttributes:
ClassColumn with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsClassColumn'};
AliasColumn with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsAliasColumn'};
ParentColumn with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsParentColumn'};
Syntax |
$self->modifyUsedAttributes($hUsedAttributes, $ColumnIndex);
|
Input |
- $hUsedAttributes (ref.hash)
- used attributes
- $ColumnIndex (integer)
- current column
|
processImportedImageAttribute
EPG-9416: Handler method to fetch object images from the MediaGallery.
Syntax |
$self->processImportedImageAttribute(
$Object, $hOldAttributes, $hDirectAttributes,
$AttributeName, $ScaleImages
);
|
Example |
$self->processImportedImageAttribute(
$Category, $hOldAttributes, $hDirectAttributes, 'ImageSmall', 0
);
|
Input |
- $Object (object)
- Category object which was imported
- $hOldAttributes (ref.hash or undefined)
- attributes of the object before the import.
May be undef if the product is created new and not modified.
- $hDirectAttributes (ref.hash)
- current Category's direct attribute values
- $AttributeName (string)
- Name of the attribute
- $ScaleImages
- boolean value if automatic generation of other image sizes
should be applied. The parameter is just supplied to the processMediaGalleryImage method, which implemention may differ in derived classes.
- $hScaleDimension (ref.hash)
- Width and Height for the scaled image
|
processMediaGalleryImage
Copies the product image from the given source and generates its
scaled variations. Updates the given attribute hash with the image names.
Syntax |
$hNewAttributes = $self->_processMediaGalleryImage(
$hDirectAttributes,
$SourceFileName,
$TargetFileName
);
|
Example |
$hDirectAttributes = $self->_processMediaGalleryImage(
$hDirectAttributes,
$MGNewImageLargeAbs,
$Product->get('PublicPath') . '/' . $NewImageLargeFileName.$NewImageLargeExtension
);
|
Input |
- $Object (object)
- Category object which was imported
- $SourceFileName (string)
- full file path and name of the source image
- $TargetFileName (string)
- full file path and name for the target image
- $ScaleImages
- boolean value if automatic generation of other image sizes
should be applied.
- $hScaleDimension (ref.hash)
- Width and Height for the scaled image
- $DoNotUpdateAttributes (boolean)
- boolean value whether product attributes should be
updated
|
Return |
- $hDirectAttributes (ref.hash)
- updated direct attribute values
|
testHeaderColumn
test $hHeader,
throws Errors NO_MONEY_FORMAT, NO_SHOP_CURRENCY, NO_SHOP_TAXMODEL, NO_SHOP_LANG, WRONG_FORMAT
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
|
throwImageMissingWarning
Check image file given using AttributeName and the hAttributeValues hash
is a URL string. Otherwise throw a warning that the image which is
referenced in the CSV file is missing.
Syntax |
$self->throwImageMissingWarning($Object, $NewImageFile);
|
Input |
- $Object (object)
- object which is imported
- $NewImageFile (ref.hash)
- image file name attribute values
- $AttributeName (string)
- Name of the attribute
|