开发者

import custom xml file to magento

I have an xml file that co开发者_如何学Gontains in products. File's structure this:

<?xml version="1.0" encoding="iso-8859-2"?>
  <service >
   <product id="2476" sku="SA 177-2" category="51" visible="1" >
     <title><![CDATA[Fedde Le Grand - OUTPUT]]></title>
     <short><![CDATA[Fedde Le Grand presents OUTPUT...]]</short>
     <long />
     <category><![CDATA[elektronika/dance/ambient]]></category>
     <price>1600</price>
     <vat>25</vat>
     <image>200909/92917a17f143088ce219_20090907.jpg</image>
     <actor><![CDATA[Fedde le Grand]]></actor>
     <album><![CDATA[Output]]></album>
     <label><![CDATA[CLS]]></label>
     <type><![CDATA[Audio CD]]></type>
   </product>
  </service>

I would like to use magento's import system, but it does not work. I set maps in Profile Actions XML. This file's structure:

<action type="dataflow/convert_parser_xml_excel" method="parse">
    <var name="single_sheet"><![CDATA[]]></var>
    <var name="fieldnames"></var>
    <var name="map">
        <map name="product_category"><![CDATA[category_ids]]></map>
        <map name="product_sku"><![CDATA[sku]]></map>
        <map name="title"><![CDATA[name]]></map>
        <map name="short"><![CDATA[short_description]]></map>
        <map name="long"><![CDATA[description]]></map>
        <map name="price"><![CDATA[price]]></map>
        <map name="vat"><![CDATA[tax_class_id]]></map>
        <map name="image"><![CDATA[image]]></map>
        <map name="actor"><![CDATA[meta_description]]></map>
        <map name="album"><![CDATA[meta_title]]></map>
        <map name="label"><![CDATA[meta_keyword]]></map>
        <map name="type"><![CDATA[samples_title]]></map>
    </var>
    <var name="store"><![CDATA[0]]></var>
    <var name="number_of_records">1</var>
    <var name="decimal_separator"><![CDATA[.]]></var>
    <var name="adapter">catalog/convert_adapter_product</var>
    <var name="method">parse</var>
</action>

.result is FOUND 0 ROWS, so it failed. Anyone could help me? I don't understand this problem. Greetings, Roland Dercsenyi


You have to write your own parser class and then use the advanced profiles. The convert_parser_xml_excel expects a file in the excel xml format. If you look at the Mage_Dataflow_Model_Convert_Parser_Xml_Excel::parse() function you'll see it expects a different xml format than you have.

//excerpt from Mage_Dataflow_Model_Convert_Parser_Xml_Excel::parse()
    $worksheet = $this->getVar('single_sheet', '');

            $xmlString = $xmlRowString = '';
            $countRows = 0;
            $isWorksheet = $isRow = false;
            while (($xmlOriginalString = $batchIoAdapter->read()) !== false) {
                $xmlString .= $xmlOriginalString;
                if (!$isWorksheet) {
                    $strposS = strpos($xmlString, '<Worksheet');
                    $substrL = 10;
                    //fix for OpenOffice
                    if ($strposS === false) {
                        $strposS = strpos($xmlString, '<ss:Worksheet');
                        $substrL = 13;
                    }

To resume:

  1. you have to use the advanced profiles and write your own parser function
  2. use the xml import profile as a base and write your own class and parse function using the Mage_Dataflow_Model_Convert_Parser_Xml_Excel as a demo
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜