Package DE_EPAGES::ShopCSVExportImport::API::CSV::ShopObjectImportHandler
This module implements a handler to import shop objects
Base |
DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler |
Example |
use DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler; DE_EPAGES::CSVExportImport::API::CSV::ObjectImportHandler->importCSV($FileName, $hFileFormat, $Shop); |
Functions
- analyzeHeaderLine
- fixObjectFileAttributes
- getUsedAttribute
- importObject
- importSpecialData
- loadShopObject
- modifyObject
- modifyUsedAttributes
- processImportedImageAttribute
- processMediaGalleryImage
- testHeaderColumn
- testMissingFields
- throwImageMissingWarning
analyzeHeaderLine
Overwrites base method to previously add some specific Shop Items, like locales, units and so on
Syntax |
my $hUsedAttributes = $self->analyzeHeaderLine(); |
Return |
|
fixObjectFileAttributes
Removes any paths from the image file name attributes of the given object.
Syntax |
$self->fixObjectFileAttributes($Object, \@AttributeNames, $LanguageID); |
Example |
$self->fixObjectFileAttributes($Product, ['ImageLarge', 'ImageMedium', 'ImageSmall', 'ImageHotDeal'],1); |
Input |
|
getUsedAttribute
return attribute info, called by analyzeHeaderLine throws Error 'UNKNOWN_ATTR' if $hHeader->{'AliasString'} isn't a key of $self->attributes call function testHeaderColumn before return $hAttribute
Syntax |
$self->getUsedAttribute($HeaderString, $ColumnIndex); |
Input |
|
Return |
|
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 |
|
loadShopObject
loads the object specified by object path and verifies that it exists, belongs to the given parentobject and is an instance of a certain class. Returns undef if path doesn't exist or object doesn't belong to the same shop. Returns the object if all tests passed.
Syntax |
$Object = $self->loadShopObject( $Shop, $Path, $ClassAlias ) |
Input |
|
Return |
|
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, $hDirectAttributes, $hAttributeValues); |
Input |
|
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 |
|
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 |
|
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 |
|
Return |
|
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 |
|
testMissingFields
throws error 'MISSING_FIELD', if field Alias is missing
Syntax |
$self->testMissingFields($hUsedAttributes); |
Input |
|
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 |
|