Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay only in stock options for configurable products on catalog pages in Magento
    primarykey
    data
    text
    <p>I've managed to add options to configurable products on my catalog pages using the code found here: <a href="http://www.magentocommerce.com/boards/viewthread/21039/P45/#t167724" rel="nofollow">http://www.magentocommerce.com/boards/viewthread/21039/P45/#t167724</a>. What I'd like to do now is only show the options that are available according to the stock of the simple product that the option is coming from. </p> <p>For example, if I have a t-shirt (configurable product) that has various colors (simple products) and my red color is out of stock, red wouldn't be shown as an option when the configurable product is displayed. </p> <p>What's the best way to do this?</p> <p><strong>Update:</strong> For the sake of clarity, here is the relevant block of code from the link I posted.</p> <pre><code>&lt;?php if($product-&gt;getTypeId() == "configurable"): ?&gt; &lt;?php $attValConfig = $product-&gt;getTypeInstance()-&gt;getConfigurableAttributesAsArray(); ?&gt; &lt;?php if(sizeof($attValConfig)): ?&gt; &lt;?php foreach($attValConfig as $attValConfigSingle): ?&gt; &lt;fieldset class="product-options" id="product-options-wrapper"&gt; &lt;label&gt;&lt;?php echo $attValConfigSingle['label']; ?&gt;:&lt;/label&gt; &lt;select name="super_attribute[&lt;?php echo $attValConfigSingle['attribute_id'] ?&gt;]" id="attribute&lt;?php echo $_product-&gt;getId() ?&gt;" class="required-entry super-attribute-select"&gt; &lt;?php foreach($attValConfigSingle['values'] as $attValConfigSingleVal): ?&gt; &lt;option value="&lt;?php echo $attValConfigSingleVal['value_index'] ?&gt;"&gt;&lt;?php echo $attValConfigSingleVal['label'] ?&gt;&lt;/option&gt; &lt;?php endforeach; ?&gt; &lt;/select&gt; &lt;/fieldset&gt; &lt;?php endforeach; ?&gt; &lt;?php endif; ?&gt; &lt;?php endif; ?&gt; </code></pre> <p>Since this code is simply getting all of the configurable options and displaying them, it doesn't check to see if the simple product that backs the configurable option is in stock. How do I do this?</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.
 

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