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

Package DE_EPAGES::Product::API::CSV::ProductImportHandler

This module implements a handler to import products

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

Functions

analyzeAttributeLine
baseAttributeClassAlias
importSpecialData
modifyUsedAttributes
processMediaGalleryImage

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();
Example
hAttributeValues='HASH
    'DirectAttributes'  =>'HASH'
        'Alias' =>'js_3200705005'
        'AvailabilityDate'  => undef
        'Class' =>'DE_EPAGES::Product::API::Object::ProductType=HASH'
        'ImageLarge'    =>'js_3200705005.jpg'
        'ImageMedium'   =>'js_3200705005_m.jpg'
        'ImageSmall'    =>'js_3200705005_s.jpg'
        'IsAvailable'   =>'1'
        'IsBundleProduct'   =>'0'
        'IsDailyPrice'  =>'0'
        'IsDefault' =>'0'
        'IsNew' =>'0'
        'IsVisible' =>'1'
        'Length'    => undef
        'Manufacturer'  =>'Tatonka'
        'ManufacturerSKU'   => undef
        'MinOrder'  =>'1'
        'OrderUnit' =>'DE_EPAGES::Object::API::Object::UnitOfMeasurement=HASH'
        'Parent'    =>'DE_EPAGES::Product::API::Object::ProductFolder=HASH'
        'PriceQuantity' =>'1'
        ....
    'DoNotImport'   =>'0'
    'LocalizedAttributes'   =>'HASH'
        '1' =>'HASH'
            'Description'   =>'Wanderrucksack mit effektiver R?el?'
            'Name'  =>'Tatonka Vento'
        '2' =>'HASH'
            'Description'   =>'Hiking Backpack with effective back ventilation'
            'Name'  =>'Tatonka Vento'
    'Object'    =>'DE_EPAGES::Product::API::Object::Product=HASH'
    'PriceAttributes'   =>'HASH'
        'EUR/1' =>'HASH'
            'CurrencyID'    =>'EUR'
            'Price' =>'69.95'
            'TaxModel'  =>'1'
        'USD/1' =>'HASH'
            'CurrencyID'    =>'USD'
            'Price' =>'69.95'
            'TaxModel'  =>'1'
    'VariationValueIDs' =>'ARRAY'
            [0] =>  '3407'
            [1] =>  '3403'
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
  • PriceAttributes - price attributes hash with CurrencyID/TaxModel as key e.g. ('EUR/1') -ref.hash
  • VariationValueIDs - variation value ids which are used at the subproduct - ref.array
  • PreDefMultiValueIDs - value ids for a multiple-choice option attribute - ref.hash.array.int

baseAttributeClassAlias

return Base AttributeClass Alias, here : 'ProductClass'

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

importSpecialData

possibility to import special object data, called by importObject saves Product Prices and super product SelectedVariations

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

modifyUsedAttributes

add keys: $hUsedAttributes->{$ColumnIndex}{'IsSuperProductAliasColumn'} = $hUsedAttributes->{$ColumnIndex}{'Alias'} eq 'SuperProduct' ? 1 : 0; $hUsedAttributes->{'SuperProductAliasColumn'} with value=$ColumnIndex if $hUsedAttributes->{$ColumnIndex}{'IsSuperProductAliasColumn'};

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

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
$hDirectAttributes (ref.hash)
direct attribute values
$ScaleImages
boolean value if automatic generation of other image sizes
should be applied.
$hScaleDimension (
ref.hash)
Width and Height for the scaled image. unused here.
$DoNotUpdateAttributes (boolean)
boolean value whether product attributes should be
updated