23/09/2013 12:34pm

PHP | Problem - ArticleCsvBulkLoader


<?php

class ArticleCsvBulkLoader extends CsvBulkLoader {
public $columnMap = array(
'ShortNumber' => 'Article.ShortNumber',
'ArtName' => 'Article.ArtName',
'Number' => 'Number',
'Color' => 'Color',
'KW1' => 'KW1',
'KW1Qty' => 'KW1Qty',
'KW2' => 'KW2',
'KW2Qty' => 'KW2Qty',
'KW3' => 'KW3',
'KW3Qty' => 'KW3Qty',
'Future' => 'Future'
);

public $duplicateChecks = array(
'Number' => 'Number'
);

public $relationCallbacks = array(
'Article.ShortNumber' => array(
'relationname' => 'Article',
'callback' => 'getShortNumber'
),
'Article.ArtName' => array(
'relationname' => 'Article',
'callback' => 'getArticleName'
)
);

public static function getShortNumber(&$obj, $val, $record) {
return Articles::get()->filter('ShortNumber', $val)->First();
}

public static function getArticleName(&$obj, $val, $record) {
return Articles::get()->filter('ArtName', $val)->First();
}

}
?>


Post Comment