[TYPO3-english] external_import, nesting pages

David Greiner davidgreiner at gmx.net
Fri Jan 30 12:23:36 CET 2015


Hi at all!

I am trying to import some external data with EXT:external_import.

A CSV file filled with magento categories should be imported as pages in
typo3.

The import is still working but i am having problems with the nesting of
subcategories.

My CSV looks like

name,category_id,parent_id
cat1,1,0
cat2,2,0
cat3,3,1


cat3 should be a child of cat1.

The external "category_id" is stored in an extra field called
"tx_vtmmage_magento_category_id" in the pages table  - and name is
mapped to the title. This works.

----------------------------
$GLOBALS['TCA']['pages']['ctrl']['external'] = array(
     0 => array(
         'connector' => 'csv',
         'parameters' => array(
             'filename' => PATH_site . 'typo3temp/test4.csv',
             'delimiter' => ",",
             'text_qualifier' => '"',
             'skip_rows' => 1,
             'encoding' => 'utf8'
         ),
         'data' => 'array',
         'reference_uid' => 'tx_vtmmage_magento_category_id',
         'priority' => 10,
         'description' => 'Import Magento Categories as pages',
         'pid' => 97
//        'disabledOperations' => 'insert'
     )
);

$GLOBALS['TCA']['pages']['columns']['title']['external'] = array(
     0 => array(
         'field' => 'name'
     )
);
$GLOBALS['TCA']['pages']['columns']['doktype']['external'] = array(
     0 => array(
         'value' => '1091'
     ),
);
$GLOBALS['TCA']['pages']['columns']['tx_vtmmage_magento_category_id']['external']
= array(
     0 => array(
         'field' => 'category_id'
     ),
);

-----------------

For assigning the child categories, I think I have to define external
pid field and an userfunction to transform the value.



$GLOBALS['TCA']['pages']['columns']['pid']['external'] = array(
     0 => array(
         'field' => 'parent_id',
         'userFunc' => array(
             'class' =>
'EXT:vtm_mage/class.tx_externalimport_transformations.php:tx_externalimport_transformations',
             'method' => 'checkPid'
         )
     )
);


In this userfunction i check for currently existing pages which
"tx_vtmmage_magento_category_id" == "the current external parent_id". If
there is a result, the uid of this page will be returned and should be
used as pid for the new record.

Unfortunately this pid gets overridden while importing and all new
records gets defined 'pid' => 97" from the ctrl section.

What is wrong in my configuration?


David.



More information about the TYPO3-english mailing list