Magento Forum

   
Import Column Name
 
aposadi
Jr. Member
 
Total Posts:  19
Joined:  2013-01-06
 

Hello to all,
i have this problem:
I need to import products from e csv with standard column name.
I setted a Dataflow import where i configurated the fieldmap. Each field in csv has a magento’s attributes (for example IPCODE in csv is ‘sku’ in Magento).

But that doesn’t work.
Magento import without looking the column name, but only the order of the columns ( so if i have field in csv that i don’t want to import they are imported).

And i have any csv’s field that i want to import in 2 different magento’s attributes (for example i want that magento take the valor in the column IP_CODE and put that in ‘sku’ attribute and in ‘ip_code’ attribute, that i created).

I tried everything, so i think that i need to change any function in core ( with custom local function), but i’m looking for any advice about this problem.

PS: i can’t change the csv, because i take it from a SOAP external call that i can’t develop in different way

PPS: Sorry for my bad english

 
Magento Community Magento Community
Magento Community
Magento Community
 
aposadi
Jr. Member
 
Total Posts:  19
Joined:  2013-01-06
 

I resolved the first problem, but not the second one:

i changed the parser csv (customized the core), from line 100 (the core class is Mage_Dataflow_Model_Convert_Parser_Csv)

$countRows 0;
        
$columnnames=array();
        
$columnnum=array();
        while ((
$csvData $batchIoAdapter->read(true$fDel$fEnc)) !== false{
            
if (count($csvData) == && $csvData[0] === null{
                
continue;
            
}

            $itemData 
= array();
            
            if(
$countRows==0){
                $columnnames
=array_keys($fieldNames);
                
$j=0;
                for (
$k 0;$k<count($csvData);$k++) {
                    
foreach($columnnames as $columnname){
                        
if($csvData[$k]==$columnname){
                            $columnnum[$j] 
$k;
                            
$j++;
                        
}
                    }
                }
            }
            $countRows
++; $i 0;
            foreach (
$fieldNames as $field{
                $itemData[$field] 
= isset($csvData[$columnnum[$i]]) ? $csvData[$columnnum[$i]] null;
                
$i++;
            
}
            $batchImportModel 
$this->getBatchImportModel()
                ->
setId(null)
                ->
setBatchId($this->getBatchModel()->getId())
                ->
setBatchData($itemData)
                ->
setStatus(1)
                ->
save();
        
}

That parse only the field that I configurated in my dataflow profile, in field mapping.

But the second problem, about to use one csv field for change 2 product\’s attributes is not resolved yet.

Please answer me with any advice!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top