0

I want to import product using simple xml file like this..

<?xml version="1.0" encoding="UTF-8"?>
<products>
    <product>

        <name>Apricot Comfy Feel Beach Maxi Skirt</name>

        <sku>sdpo12</sku>

        <long_description>A lovely</long_description>


        <price>19.23</price>


        <attribute_set>Default</attribute_set>

        <type>simple</type>

        <meta_description>A lovely apricot maxi skirt is</meta_description>

        <short_description>A lovely apricot maxi</short_description>

        <stock>102</stock>

        <weight>2</weight>
    </product>

</products>

after import..output comes like this---> found 0 rows..

Starting Mage_Dataflow_Model_Convert_Parser_Xml_Excel :: parse
Found 0 rows.
Starting catalog/convert_adapter_product :: parse 

earlier i used xml file like this--> (which successfully import my products)

<?mso-application progid="Excel.Sheet"?><Workbook><OfficeDocumentSettings><Colors><Color><Index>3</Index><RGB>#c0c0c0</RGB></Color><Color><Index>4</Index><RGB>#ff0000</RGB></Color></Colors></OfficeDocumentSettings><ExcelWorkbook><WindowHeight>9000</WindowHeight><WindowWidth>13860</WindowWidth><WindowTopX>240</WindowTopX><WindowTopY>75</WindowTopY><ProtectStructure>False</ProtectStructure><ProtectWindows>False</ProtectWindows></ExcelWorkbook><Styles><Style ss:ID="Default" ss:Name="Default"/><Style ss:ID="Result" ss:Name="Result"><Font ss:Bold="1" ss:Italic="1" ss:Size="10" ss:Underline="Single"/></Style><Style ss:ID="Result2" ss:Name="Result2"><Font ss:Bold="1" ss:Italic="1" ss:Size="10" ss:Underline="Single"/><NumberFormat ss:Format="Currency"/></Style><Style ss:ID="Heading" ss:Name="Heading"><Font ss:Bold="1" ss:Italic="1" ss:Size="16"/></Style><Style ss:ID="Heading1" ss:Name="Heading1"><Font ss:Bold="1" ss:Italic="1" ss:Size="16"/></Style><Style ss:ID="co1"/><Style ss:ID="ta1"/><Style ss:ID="ce1"><Font ss:FontName="Liberation Sans1" ss:Size="10"/></Style><Style ss:ID="ce2"><Font ss:FontName="Liberation Sans11" ss:Size="10"/></Style></Styles><ss:Worksheet ss:Name="Sheet 1"><Table ss:StyleID="ta1"><Column ss:Span="16" ss:Width="64.0063"/><Row ss:AutoFitHeight="0" ss:Height="12.8126"><Cell><Data ss:Type="String">name</Data></Cell><Cell><Data ss:Type="String">sku</Data></Cell><Cell><Data ss:Type="String">price</Data></Cell><Cell><Data ss:Type="String">weight</Data></Cell><Cell><Data ss:Type="String">description</Data></Cell><Cell><Data ss:Type="String">short_description</Data></Cell><Cell><Data ss:Type="String">status</Data></Cell><Cell><Data ss:Type="String">visibility</Data></Cell><Cell><Data ss:Type="String">tax_class_id</Data></Cell><Cell><Data ss:Type="String">qty</Data></Cell><Cell><Data ss:Type="String">type</Data></Cell><Cell><Data ss:Type="String">attribute_set</Data></Cell><Cell><Data ss:Type="String">websites</Data></Cell><Cell><Data ss:Type="String">is_in_stock</Data></Cell><Cell><Data ss:Type="String">size</Data></Cell><Cell><Data ss:Type="String">color</Data></Cell><Cell><Data ss:Type="String">shape</Data></Cell></Row><Row ss:AutoFitHeight="0" ss:Height="12.7559"><Cell><Data ss:Type="String">Done</Data></Cell><Cell><Data ss:Type="String">dm01a</Data></Cell><Cell><Data ss:Type="Number">22</Data></Cell><Cell><Data ss:Type="Number">43</Data></Cell><Cell><Data ss:Type="String">this is first product</Data></Cell><Cell><Data ss:Type="String">this is first product</Data></Cell><Cell><Data ss:Type="String">Enabled</Data></Cell><Cell><Data ss:Type="String">Not Visible Individually</Data></Cell><Cell><Data ss:Type="String">None</Data></Cell><Cell><Data ss:Type="Number">0</Data></Cell><Cell><Data ss:Type="String">simple</Data></Cell><Cell><Data ss:Type="String">Clothing</Data></Cell><Cell><Data ss:Type="String">base</Data></Cell><Cell><Data ss:Type="Number">1</Data></Cell><Cell><Data ss:Type="Number">12</Data></Cell><Cell><Data ss:Type="String">red</Data></Cell><Cell><Data ss:Type="String">circle</Data></Cell></Row>
</Table><x:WorksheetOptions/></ss:Worksheet></Workbook>

But i dont want to use this type of xml to import product... Can anyone help me , how to import product using simple xml file...

7
  • remove the blank lines from your xml file and than try
    – Charlie
    May 2, 2016 at 5:16
  • after removing blanks, output-> Starting Mage_Dataflow_Model_Convert_Parser_Xml_Excel :: parse Found 0 rows. (it's same output) May 2, 2016 at 6:09
  • there is lots of difference between your first XML and second XML file, Do you changed the products import code according to your new XML file format?
    – Charlie
    May 2, 2016 at 6:16
  • 2nd file is just a example....its excel xml file......that contain...<?mso-application progid="Excel.Sheet"?><Workbook><OfficeDocumentSettings>.....etc... my first file is simple xml file....Do i create my own parser.....to import this file...? May 2, 2016 at 6:37
  • Maybe github.com/code4business/xmlimport is interesting for you, it's an XML adapter for the standard Magento CSV import and it's probably easier to convert your XML structure to the structure expected by the xmlimport module than writing your own parser for the dataflow profile (which are much slower, by the way) May 4, 2016 at 7:29

1 Answer 1

1

Pretty sure Magento doesn't come with a dataflow parser for XML out of the box, only Microsoft Excel and CSV.

It's also relatively difficult for a parser to cater to every possible XML structure compared to, let's say, 2D column/row based data such as Excel or CSV.

If you're a developer it shouldn't be difficult to create your own parser that suits your XML structure. It's basically a SimpleXml loadstring call and saving every (batch) row(s) in a batch import model.

Check out Mage_Dataflow_Model_Convert_Parser_Csv for inspiration.

5
  • Do i need to create new file -> Xml.php like csv.php (under -> Mage_Dataflow_Model_Convert_Parser_Csv) & perform my code inside Mage_Dataflow_Model_Convert_Parser_Xml.php May 2, 2016 at 7:17
  • @Pankaj, it's slightly more complicated than that. I can point you in the right direction, but don't have the time to fully explain it. I would create a new Magento extension that defines a model class like: Pankaj_Dataflow_Model_Convert_Parser_Xml. And then in the advanced dataflow profile XML you can tell the profile to use your custom model.
    – Erfan
    May 2, 2016 at 7:21
  • @irfan... i create my custom file (under local/Mage/Dataflow/Model/Convert/Parser/Xml.php).....but its not working.... May 2, 2016 at 10:31
  • @Pankaj Check this on how to develop for Magento: alanstorm.com/category/magento
    – Erfan
    May 3, 2016 at 7:15
  • @irfan .. i checked each link of that site...but there is no reference or link to import simple xml product. May 3, 2016 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.