Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ public function getImageType()
*/
protected function _toHtml()
{
if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled
// Check if swatches are enabled for either listing or product detail
if (!Mage::helper('configurableswatches')->isEnabled()
&& !Mage::helper('configurableswatches')->isEnabledForProductDetail()
) {
return ''; // do not render block
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_ConfigurableSwatches_Block_Catalog_Product_View_Type_Configurable_Swa
*/
public function shouldRender($attribute, $jsonConfig)
{
if (Mage::helper('configurableswatches')->isEnabled()) {
if (Mage::helper('configurableswatches')->isEnabledForProductDetail()) {
if (Mage::helper('configurableswatches')->attrIsSwatchType($attribute->getProductAttribute())) {
$this->_init($jsonConfig);
return true;
Expand Down
16 changes: 14 additions & 2 deletions app/code/core/Mage/ConfigurableSwatches/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Mage_ConfigurableSwatches_Helper_Data extends Mage_Core_Helper_Abstract
protected $_configAttributeIds = null;

/**
* Is the extension enabled?
* Is the extension enabled for product listing?
* Requires both general enabled flag and listing attribute to be set.
*
* @return bool
*/
Expand All @@ -43,6 +44,17 @@ public function isEnabled()
return $this->_enabled;
}

/**
* Is the extension enabled for product detail page?
* Only requires general enabled flag, independent of listing configuration.
*
* @return bool
*/
public function isEnabledForProductDetail()
{
return Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLED);
}

/**
* Return the formatted hyphenated string
*
Expand Down Expand Up @@ -126,7 +138,7 @@ public function getSwatchesProductJs()
{
/** @var Mage_Catalog_Model_Product $product */
$product = Mage::registry('current_product');
if ($this->isEnabled() && $product) {
if ($this->isEnabledForProductDetail() && $product) {
$configAttrs = $this->getSwatchAttributeIds();
/** @var Mage_Catalog_Model_Product_Type_Configurable $productType */
$productType = $product->getTypeInstance(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ public function clearSwatchesCache()
*/
public function filterImageInGallery($product, $image)
{
if (!Mage::helper('configurableswatches')->isEnabled()) {
// Check if swatches are enabled for either listing or product detail
if (!Mage::helper('configurableswatches')->isEnabled()
&& !Mage::helper('configurableswatches')->isEnabledForProductDetail()
) {
return true;
}

Expand Down
10 changes: 8 additions & 2 deletions app/code/core/Mage/ConfigurableSwatches/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public function productListCollectionLoadAfter(Varien_Event_Observer $observer)
*/
public function productLoadAfter(Varien_Event_Observer $observer)
{
if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled
// Check if swatches are enabled for either listing or product detail
if (!Mage::helper('configurableswatches')->isEnabled()
&& !Mage::helper('configurableswatches')->isEnabledForProductDetail()
) {
return; // exit without loading swatch functionality
}

Expand All @@ -91,7 +94,10 @@ public function productLoadAfter(Varien_Event_Observer $observer)
*/
public function loadChildProductImagesOnMediaLoad(Varien_Event_Observer $observer)
{
if (!Mage::helper('configurableswatches')->isEnabled()) { // functionality disabled
// Check if swatches are enabled for either listing or product detail
if (!Mage::helper('configurableswatches')->isEnabled()
&& !Mage::helper('configurableswatches')->isEnabledForProductDetail()
) {
return; // exit without loading swatch functionality
}

Expand Down
Loading