Dependent Custom Options 1.8   May 22 2013


This addition makes product custom options dependent. So you can set different size for different gender.
Or display a file upload field if a customer wants to upload a sample.
This extension has "Import options from other product" and dataflow .csv Import / Export features.
So you can copy options from one product to another.



Index:




Installation with Connect Manager

1) Disable magento compilation in Magento admin panel -> System -> Tools -> Compilation

2) Go to System -> Magento Connect -> Magento Connect Manager (screenshot)
3) Uncheck the "Put store on the maintenance mode" checkbox.
4) Choose file "package_for_magento_connect_manager_installation.tgz" and click the Upload button.

Screenshot

If your website uses custom theme directory /Custom_Theme/default/
Follow the Copy design and skin files section.



Manual Installation

1) Disable magento compilation in Magento admin panel -> System -> Tools -> Compilation

2) Upload 29 new files :

app/code/local/Pektsekye/OptionDependent/Block/Adminhtml/Catalog/Product/Edit/Js.php
app/code/local/Pektsekye/OptionDependent/Block/Product/View/Js.php
app/code/local/Pektsekye/OptionDependent/etc/config.xml
app/code/local/Pektsekye/OptionDependent/Helper/Data.php
app/code/local/Pektsekye/OptionDependent/Model/Observer.php
app/code/local/Pektsekye/OptionDependent/Model/Import.php
app/code/local/Pektsekye/OptionDependent/Model/Option.php
app/code/local/Pektsekye/OptionDependent/Model/Value.php
app/code/local/Pektsekye/OptionDependent/Model/Convert/Adapter/Options.php
app/code/local/Pektsekye/OptionDependent/Model/Convert/Parser/Options.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Import.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Option.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Value.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Import/Collection.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Option/Collection.php
app/code/local/Pektsekye/OptionDependent/Model/Mysql4/Value/Collection.php
app/code/local/Pektsekye/OptionDependent/Model/Quote.php
app/code/local/Pektsekye/OptionDependent/Model/Resource/Eav/Mysql4/Product/Option.php
app/code/local/Pektsekye/OptionDependent/sql/optiondependent_setup/mysql4-install-0.1.0.php
app/design/adminhtml/default/default/layout/optiondependent.xml
app/design/adminhtml/default/default/template/optiondependent/catalog/product/edit/js.phtml
app/design/adminhtml/default/default/template/optiondependent/catalog/product/composite/configure/js.phtml
app/design/frontend/default/default/layout/optiondependent.xml
app/design/frontend/default/default/template/optiondependent/product/view/js.phtml
app/etc/modules/Pektsekye_OptionDependent.xml
app/locale/en_US/Pektsekye_OptionDependent.csv
js/pektsekye/option_dependent.js
js/pektsekye/order_create/option_dependent.js
skin/adminhtml/default/default/optiondependent.css


3) Refresh the Magento cache in
Magento admin panel -> System -> Cache Management



Copy design and skin files into your custom theme directory

If your site uses a custom front-end theme. Copy 2 files from:
   app/design/frontend/default/default/layout/optiondependent.xml
   app/design/frontend/default/default/template/optiondependent/product/view/js.phtml

to:
   app/design/frontend/YOUR_INTERFACE/default/layout/optiondependent.xml
   app/design/frontend/YOUR_INTERFACE/default/template/optiondependent/product/view/js.phtml

NOTE: Don't forget to refresh the magento cache after any of the layout changes.
Magento admin panel -> System -> Cache Management

Back to the index


An example of how to set dependency

1) Go to Magento admin panel -> Catalog -> Edit Product
2) Find a product with type Simple Product and without custom options then click the "Edit" link.
3) Add the custom option to it: Title - "Gender", Input Type - "Drop-down", Sort Order - "1".
4) Add rows to it: "Mens", "Womens".
5) Add the second custom option: Title - "Size", Input Type - "Drop-down", Sort Order - "2".
6) Add four rows with titles: "3", "4", "8", "9".
7) Scroll the page back to the "Gender" option.
8) Find the "Children" field of the "Mens" row.
9) Enter two row ids of the "Size" option separated with commas: 5,6.
10) Find the "Children" field of the "Womens" row.
11) Enter another two row ids of the "Size" option: 3,4.
12) Check everything with the screenshot.
13) Click the "Save And Continue Edit " button.
14) Navigate to your product in the Front end.
15) Check when select gender "Mens" the size option must appear with two values 8 and 9. (screenshot)

Back to the index


Import options from another product:

1) Go to Magento admin panel -> Catalog -> Edit Product
2) Find a product with type Simple Product and without custom options then click the "Edit" link.
3) Select "Custom Options" in the right menu.
4) Enter the SKU number of the product that you want to import options from it into the "Import options from product" field. (screenshot)
5) Click the "Save And Continue Edit " button.

NOTE: The "Import options from product" field only appears when a product does not have custom options.

Back to the index


To export options

1) Go to Magento admin panel -> System -> Import/Export -> Advanced Profiles (screenshot)
2) Click the "Add New Profile" button. (screenshot)
3) Fill in the fields:
Profile name - "optiondependent-export"
Actions XML -
<action type="optiondependent/convert_parser_options" method="unparse">
</action>
<action type="dataflow/convert_mapper_column" method="map">
</action>
<action type="dataflow/convert_parser_csv" method="unparse">
<var name="delimiter"><![CDATA[,]]></var>
<var name="enclose"><![CDATA["]]></var>
<var name="fieldnames">true</var>
</action>

<action type="dataflow/convert_adapter_io" method="save">
<var name="type">file</var>
<var name="path">var/export</var>
<var name="filename"><![CDATA[export_options.csv]]></var>
</action>

4) Click the "Save and Continue Editing" button.
5) Select "Run Profile" in the right menu and click the "Run Profile In Popup" button. (screenshot)
6) Find the generated export_options.csv file in var/export (screenshot)

Back to the index


To import options


1) Prepare options data with the Excel program:
Required fields are four:
"product_sku", "option_title", "type" and "value_title" (when type is "drop_down", "radio", "checkbox" or "multiple").
Valid option types are:
"field", "area", "file", "drop_down", "radio", "checkbox", "multiple", "date", "date_time", "time"
Valid price types are:
"fixed", "percent"

The "row_id" field must be unique for one product .
It means that one product cannot have repeated ids but two different products can have the same row ids.
This field cannot be empty if the product already has other row ids.

The "children" field contains comma separated row ids of other options of that product.
It must contain only the row ids that the product has.
Or it can be empty.

So the fields "row_id" and "children" are optional and you don't need to fill them.
But if you filled one of them you must fill the rest for that product.


Check a sample import file.

2) Save it as "import_options.csv" file and upload it to var/import directory
3) Go to Magento admin panel -> System -> Import/Export -> Advanced Profiles
4) Click the "Add New Profile" button.
5) Fill in the fields:
Profile name - "optiondependent-import"
Actions XML -
<action type="dataflow/convert_adapter_io" method="load">
<var name="type">file</var>
<var name="path">var/import/</var>
<var name="filename"><![CDATA[import_options.csv]]></var>
<var name="format"><![CDATA[csv]]></var>
</action>
<action type="dataflow/convert_parser_csv" 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="adapter">optiondependent/convert_adapter_options</var>
<var name="method">parse</var>
</action>

6) Click the "Save and Continue Editing" button.
7) Select "Run Profile" in the right menu and click the "Run Profile In Popup" button.

Back to the index