-
- wehren

-
Total Posts: 1
Joined: 2009-11-08
|
A client asked me to help out importing a bunch of products with a ton of custom options for each product. I wasn’t really fond of the syntax most of the other scripts I saw floating around, so I put this together.
This lets you specify custom options for products you’ve already entered in a more flat format, ie:
“sku”,"option_title”,"input_type”,"required”,"sort_order”,"row_title”,"row_price”,"row_price_type”,"row_sku”,"row_sort_order"
“AAA”,"A”,"drop_down”,0,0,"A1”,10,"Fixed",12343,1
“AAA”,"A”,"drop_down”,0,0,"A2”,10,"Fixed",12343,1
“AAA”,"A”,"drop_down”,0,0,"A3”,10,"Fixed",12343,1
“BBB”,"C”,"drop_down”,0,50,"B1”,10,"Fixed",12343,1
“AAA”,"B”,"drop_down”,1,10,"A4”,1,"Fixed",98765,2
“CCC”,"D”,"drop_down”,0,25,"C5”,50,"percent",1232123,5
Two pieces of code, one is a Dataflow Parser that groups the data by SKU for easier processing, and the Adapter that processes the options. I’ve only tested it with drop down inputs (since that’s all I needed), but it should be pretty easy to extend if someone else wants to. I’m sure there are plenty of bugs, but it worked fine for a quick one off project.
Action XML:
<action type="dataflow/convert_adapter_io" method="load"> <var name="type">file</var> <var name="path">var/import</var> <var name="filename"><![CDATA[options.csv]]></var> <var name="format"><![CDATA[csv]]></var> </action>
<action type="dataflow/convert_parser_chunked" method="parse"> <var name="delimiter"><![CDATA[,]]></var> <var name="enclose"><![CDATA["]]></var> <var name="fieldnames">true</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_optionimport</var> <var name="method">parse</var> </action>
File Attachments
|