Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of <code>getOptions()</code> please try <code>getCustomOptions()</code> or <code>getProductOptionsCollection()</code> or <code>getProductOptionsCollection()-&gt;load()</code>.</p> <p><strong>Edit</strong><br> I tried this on a product I knew had options.</p> <pre><code>&lt;?php require 'app/Mage.php'; Mage::app(); $product = Mage::getModel('catalog/product')-&gt;load($productId); foreach ($product-&gt;getProductOptions() as $option) { print_r($option-&gt;debug()); } </code></pre> <p>And got something like this:</p> <pre><code>Array ( [option_id] =&gt; 37 [product_id] =&gt; 8 [type] =&gt; multidate [is_require] =&gt; 1 [sku] =&gt; [image_size_x] =&gt; 0 [image_size_y] =&gt; 0 [sort_order] =&gt; 1 [default_title] =&gt; Dates [title] =&gt; Dates ) </code></pre> <p>However, <code>getOptions()</code> also worked for me so I don't know what's going on.</p> <p><strong>Post-edit</strong><br> The confusion was one of semantics. A simple product can have "custom options", they allow creation of a few form fields which are recorded as part of the order. A configurable product uses "associated products" to create a form with conditional fields. </p> <p>For example you might be selling socks that are large-green, small-green or large-blue - but no small-blue ones. With a simple product you would have a field for large/small and a field for blue/green - which allows the customer to select small-blue and that is wrong. </p> <p>So to find the component parts of a configurable you might do something like this:</p> <pre><code>if ($product-&gt;isConfigurable()) { $configurable = $product-&gt;getTypeInstance(); $childProducts = $product-&gt;getUsedProducts($product); foreach ($childProducts as $child) { // You have a $child now } } </code></pre> <p>To find the equivalent of <code>getOptions()</code> you need this:</p> <pre><code>if ($product-&gt;isConfigurable()) { $configurable = $product-&gt;getTypeInstance(); $attributes = $configurable-&gt;getConfigurableAttributes($product); // $attributes is a Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Type_Configurable_Attribute_Collection foreach ($attributes as $attribute) { // $attribute is a Mage_Catalog_Model_Product_Type_Configurable_Attribute print $attribute-&gt;getLabel(); } } </code></pre> <p><a href="http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Model_Product_Type_Configurable_Attribute.html" rel="noreferrer"><code>Mage_Catalog_Model_Product_Type_Configurable_Attribute</code></a> doesn't have much to reveal about itself.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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