diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php index 99f4f6920bf..c6290366cac 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php @@ -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 } diff --git a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php index 2eeaa8cc3f4..915909f92c0 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php +++ b/app/code/core/Mage/ConfigurableSwatches/Block/Catalog/Product/View/Type/Configurable/Swatches.php @@ -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; diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php index 4c812e5a917..4a21f7baa4e 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php @@ -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 */ @@ -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 * @@ -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); diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php index 0dac68479fc..55e64b2f8ca 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Productimg.php @@ -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; } diff --git a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php index 22de7d04409..569823e4b66 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php +++ b/app/code/core/Mage/ConfigurableSwatches/Model/Observer.php @@ -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 } @@ -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 }