Try the Demo

Magento Forum

   
Quick Cutsom Options Import
 
wehren
Jr. Member
 
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
import.zip  (File Size: 5KB - Downloads: 387)
 
Magento Community Magento Community
Magento Community
Magento Community
 
jk99
Jr. Member
 
Total Posts:  10
Joined:  2008-06-08
 

Hi!
Thanx for your contribution! I just tested it and it imports all the options as expected BUT they are not visible on frontend. Why? I discovered that all I need to do is to edit the product (after the import) and just save it again (without any modifications) and then the options are displayed. But I don’t understand why they are not displayed at once after import (and they are displayed in admin).
Any clues?

 
Magento Community Magento Community
Magento Community
Magento Community
 
jk99
Jr. Member
 
Total Posts:  10
Joined:  2008-06-08
 

oh, forgot to mention - I tried refreshing/turning off all cache settings so it’s got nothing to do with cache… (caching was my first suspect for this problem)

 
Magento Community Magento Community
Magento Community
Magento Community
 
ben_marks
Moderator
 
Avatar
Total Posts:  448
Joined:  2008-10-09
Charleston, SC
 

There’s a fantastic solution that handles this at http://www.jc-websolutions.com/mag-customops.html

 Signature 

Ben Marks, MCD+ (@benmarks)Blue Acorn, a Magento Gold PartnereCommerce Consulting
New Magento StackExchange site proposal - follow & vote!
I do not respond to PMs.

 
Magento Community Magento Community
Magento Community
Magento Community
 
AnshumaanBakshi
Member
 
Avatar
Total Posts:  33
Joined:  2008-11-14
Delhi, India
 

Excellent work friend.

I am on Magento 1.4.0.1, it works perfectly fine.

Thanx
AB

 
Magento Community Magento Community
Magento Community
Magento Community
 
zaheerabbasbadi
Jr. Member
 
Total Posts:  28
Joined:  2012-05-16
 

Hello wehren

I had successfully imported custom option with your custom code in magento ver 1.7.0 2.Thanks for that. one problem is there that is when importing price does not display in price box of admin side but it display complete at frontend i have attached image what is the problem kindly have a look and please please give the solution for the same.

Thanks.

Image Attachments
front.pngadminimage.png
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top