Skip to content

Instantly share code, notes, and snippets.

@antoinekociuba
Last active August 29, 2015 14:04
Show Gist options
  • Save antoinekociuba/9695fcaa202324aee289 to your computer and use it in GitHub Desktop.
Save antoinekociuba/9695fcaa202324aee289 to your computer and use it in GitHub Desktop.
Display out of stock options of Configurable products, depending on 'Show out of stock' system configuration setting.
<?php
/**
* Check if out of stock options of configurable products should be displayed
*/
public function checkDisplayOutOfStockOptions()
{
$currentProduct = Mage::registry('current_product');
if ($currentProduct && $currentProduct->isConfigurable()) {
if (Mage::getStoreConfigFlag(Mage_CatalogInventory_Helper_Data::XML_PATH_SHOW_OUT_OF_STOCK)) {
Mage::helper('catalog/product')->setSkipSaleableCheck(true);
}
}
}
<controller_action_layout_render_before_catalog_product_view>
<observers>
<your_module_observer_name>
<class>Your_Module_Model_Observer</class>
<method>checkDisplayOutOfStockOptions</method>
</your_module_observer_name>
</observers>
</controller_action_layout_render_before_catalog_product_view>
<controller_action_layout_render_before_checkout_cart_configure>
<observers>
<your_module_observer_name>
<class>Your_Module_Model_Observer</class>
<method>checkDisplayOutOfStockOptions</method>
</your_module_observer_name>
</observers>
</controller_action_layout_render_before_checkout_cart_configure>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment