File tree Expand file tree Collapse file tree 5 files changed +31
-7
lines changed
app/code/core/Mage/ConfigurableSwatches
Product/View/Type/Configurable Expand file tree Collapse file tree 5 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,10 @@ public function getImageType()
119119 */
120120 protected function _toHtml ()
121121 {
122- if (!Mage::helper ('configurableswatches ' )->isEnabled ()) { // functionality disabled
122+ // Check if swatches are enabled for either listing or product detail
123+ if (!Mage::helper ('configurableswatches ' )->isEnabled ()
124+ && !Mage::helper ('configurableswatches ' )->isEnabledForProductDetail ()
125+ ) {
123126 return '' ; // do not render block
124127 }
125128
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class Mage_ConfigurableSwatches_Block_Catalog_Product_View_Type_Configurable_Swa
3131 */
3232 public function shouldRender ($ attribute , $ jsonConfig )
3333 {
34- if (Mage::helper ('configurableswatches ' )->isEnabled ()) {
34+ if (Mage::helper ('configurableswatches ' )->isEnabledForProductDetail ()) {
3535 if (Mage::helper ('configurableswatches ' )->attrIsSwatchType ($ attribute ->getProductAttribute ())) {
3636 $ this ->_init ($ jsonConfig );
3737 return true ;
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ class Mage_ConfigurableSwatches_Helper_Data extends Mage_Core_Helper_Abstract
2727 protected $ _configAttributeIds = null ;
2828
2929 /**
30- * Is the extension enabled?
30+ * Is the extension enabled for product listing?
31+ * Requires both general enabled flag and listing attribute to be set.
3132 *
3233 * @return bool
3334 */
@@ -43,6 +44,17 @@ public function isEnabled()
4344 return $ this ->_enabled ;
4445 }
4546
47+ /**
48+ * Is the extension enabled for product detail page?
49+ * Only requires general enabled flag, independent of listing configuration.
50+ *
51+ * @return bool
52+ */
53+ public function isEnabledForProductDetail ()
54+ {
55+ return Mage::getStoreConfigFlag (self ::CONFIG_PATH_ENABLED );
56+ }
57+
4658 /**
4759 * Return the formatted hyphenated string
4860 *
@@ -126,7 +138,7 @@ public function getSwatchesProductJs()
126138 {
127139 /** @var Mage_Catalog_Model_Product $product */
128140 $ product = Mage::registry ('current_product ' );
129- if ($ this ->isEnabled () && $ product ) {
141+ if ($ this ->isEnabledForProductDetail () && $ product ) {
130142 $ configAttrs = $ this ->getSwatchAttributeIds ();
131143 /** @var Mage_Catalog_Model_Product_Type_Configurable $productType */
132144 $ productType = $ product ->getTypeInstance (true );
Original file line number Diff line number Diff line change @@ -377,7 +377,10 @@ public function clearSwatchesCache()
377377 */
378378 public function filterImageInGallery ($ product , $ image )
379379 {
380- if (!Mage::helper ('configurableswatches ' )->isEnabled ()) {
380+ // Check if swatches are enabled for either listing or product detail
381+ if (!Mage::helper ('configurableswatches ' )->isEnabled ()
382+ && !Mage::helper ('configurableswatches ' )->isEnabledForProductDetail ()
383+ ) {
381384 return true ;
382385 }
383386
Original file line number Diff line number Diff line change @@ -65,7 +65,10 @@ public function productListCollectionLoadAfter(Varien_Event_Observer $observer)
6565 */
6666 public function productLoadAfter (Varien_Event_Observer $ observer )
6767 {
68- if (!Mage::helper ('configurableswatches ' )->isEnabled ()) { // functionality disabled
68+ // Check if swatches are enabled for either listing or product detail
69+ if (!Mage::helper ('configurableswatches ' )->isEnabled ()
70+ && !Mage::helper ('configurableswatches ' )->isEnabledForProductDetail ()
71+ ) {
6972 return ; // exit without loading swatch functionality
7073 }
7174
@@ -91,7 +94,10 @@ public function productLoadAfter(Varien_Event_Observer $observer)
9194 */
9295 public function loadChildProductImagesOnMediaLoad (Varien_Event_Observer $ observer )
9396 {
94- if (!Mage::helper ('configurableswatches ' )->isEnabled ()) { // functionality disabled
97+ // Check if swatches are enabled for either listing or product detail
98+ if (!Mage::helper ('configurableswatches ' )->isEnabled ()
99+ && !Mage::helper ('configurableswatches ' )->isEnabledForProductDetail ()
100+ ) {
95101 return ; // exit without loading swatch functionality
96102 }
97103
You can’t perform that action at this time.
0 commit comments