Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not documented anywhere (else), but at least in Magento 1.6 one can find the appropriate API methods for product options in the source code. (I don 't know since which version that feature exists.)</p> <p>The API itself is defined in: app/code/core/Mage/Catalog/etc/api.xml</p> <pre><code>&lt;catalog_product_custom_option translate="title" module="catalog"&gt; &lt;title&gt;Catalog product custom options API&lt;/title&gt; &lt;model&gt;catalog/product_option_api&lt;/model&gt; &lt;acl&gt;catalog/product/option&lt;/acl&gt; &lt;methods&gt; &lt;add translate="title" module="catalog"&gt; &lt;title&gt;Add new custom option into product&lt;/title&gt; &lt;acl&gt;catalog/product/option/add&lt;/acl&gt; &lt;/add&gt; &lt;update translate="title" module="catalog"&gt; &lt;title&gt;Update custom option of product&lt;/title&gt; &lt;acl&gt;catalog/product/option/update&lt;/acl&gt; &lt;/update&gt; &lt;types translate="title" module="catalog"&gt; &lt;title&gt;Get list of available custom option types&lt;/title&gt; &lt;acl&gt;catalog/product/option/types&lt;/acl&gt; &lt;/types&gt; &lt;info translate="title" module="catalog"&gt; &lt;title&gt;Get full information about custom option in product&lt;/title&gt; &lt;acl&gt;catalog/product/option/info&lt;/acl&gt; &lt;/info&gt; &lt;list translate="title" module="catalog"&gt; &lt;title&gt;Retrieve list of product custom options&lt;/title&gt; &lt;acl&gt;catalog/product/option/list&lt;/acl&gt; &lt;method&gt;items&lt;/method&gt; &lt;/list&gt; &lt;remove translate="title" module="catalog"&gt; &lt;title&gt;Remove custom option&lt;/title&gt; &lt;acl&gt;catalog/product/option/remove&lt;/acl&gt; &lt;/remove&gt; &lt;/methods&gt; &lt;/catalog_product_custom_option&gt; </code></pre> <p>The called functions are defined in: app/code/core/Mage/Catalog/Model/Product/Option/Api.php</p> <pre><code>class Mage_Catalog_Model_Product_Option_Api extends Mage_Catalog_Model_Api_Resource { /** * Add custom option to product * * @param string $productId * @param array $data * @param int|string|null $store * @return bool $isAdded */ public function add( $productId, $data, $store = null ) /** * Update product custom option data * * @param string $optionId * @param array $data * @param int|string|null $store * @return bool */ public function update( $optionId, $data, $store = null ) /** * Read list of possible custom option types from module config * * @return array */ public function types() /** * Get full information about custom option in product * * @param int|string $optionId * @param int|string|null $store * @return array */ public function info( $optionId, $store = null ) /** * Retrieve list of product custom options * * @param string $productId * @param int|string|null $store * @return array */ public function items( $productId, $store = null ) /** * Remove product custom option * * @param string $optionId * @return boolean */ public function remove( $optionId ) /** * Check is type in allowed set * * @param string $type * @return bool */ protected function _isTypeAllowed( $type ) } </code></pre> <p>The <code>$data</code>-array also is a bit tricky, since it's keys partly depend on the selected option type. The basic $data-array looks like:</p> <pre><code>$data = array ( 'is_delete' =&gt; 0, 'title' =&gt; 'Custom Option Label', 'type' =&gt; 'text', 'is_require' =&gt; 0, 'sort_order' =&gt; 1, 'additional_fields' =&gt; array ( 0 =&gt; array ( 'price' =&gt; '10.0000', 'price_type' =&gt; 'fixed', // 'fixed' or 'percent' 'sku' =&gt; '', ), ), ); </code></pre> <p>The <code>additional_fields</code> always conatin at least one row with at least the columns <code>price</code>, <code>price_type</code> and <code>sku</code>. More additional fields (maf: …) may be added depending on the type. The types in the group <code>select</code> may have more than one row specified in <code>additional_fields</code>. The custom option types/type-groups are:</p> <ul> <li>text (maf: <code>'max_characters'</code>) <ul> <li>field</li> <li>area</li> </ul></li> <li>file (maf: <code>'file_extension', 'image_size_x', 'image_size_y'</code>) <ul> <li>file</li> </ul></li> <li>select (maf: <code>'value_id', 'title', 'sort_order'</code>) <ul> <li>drop_down</li> <li>radio</li> <li>checkbox</li> <li>multiple</li> </ul></li> <li>date <ul> <li>date</li> <li>date_time</li> <li>time</li> </ul></li> </ul> <p>Examples for complete option data arrays:</p> <pre><code>// type-group: select, type: checkbox $data = array ( 'is_delete' =&gt; 0, 'title' =&gt; 'extra Option for that product', 'type' =&gt; 'checkbox', 'is_require' =&gt; 0, 'sort_order' =&gt; 1, 'additional_fields' =&gt; array ( 0 =&gt; array ( 'value_id' =&gt; '3', 'title' =&gt; 'Yes', 'price' =&gt; 10.00, 'price_type' =&gt; 'fixed', 'sku' =&gt; NULL, 'sort_order' =&gt; 1, ), 1 =&gt; array ( 'value_id' =&gt; 3, 'title' =&gt; 'No', 'price' =&gt; 0.00, 'price_type' =&gt; 'fixed', 'sku' =&gt; NULL, 'sort_order' =&gt; 2, ), ), ); // type-group: text, type: field $data = array ( 'is_delete' =&gt; 0, 'title' =&gt; 'Custom Option Label', 'type' =&gt; 'text', 'is_require' =&gt; 0, 'sort_order' =&gt; 1, 'additional_fields' =&gt; array ( 0 =&gt; array ( 'price' =&gt; 10.00, 'price_type' =&gt; 'fixed', 'sku' =&gt; NULL, 'max_characters' =&gt; 150, ), ), ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload