Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ protected function _getImageSizes()
{
return ['image'];
}

/**
* Override parent to check if swatches are enabled for product detail pages
* Product detail swatches work independently of listing attribute configuration
*
* @return string
*/
protected function _toHtml()
{
// For product detail pages, only check if swatches are enabled in config
// Don't require listing attribute to be configured
if (!Mage::getStoreConfigFlag(Mage_ConfigurableSwatches_Helper_Data::CONFIG_PATH_ENABLED)) {
return ''; // do not render block
}

// Call grandparent to skip the Abstract class's isEnabled() check
return Mage_Core_Block_Template::_toHtml();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class Mage_ConfigurableSwatches_Block_Catalog_Product_View_Type_Configurable_Swa
*/
public function shouldRender($attribute, $jsonConfig)
{
if (Mage::helper('configurableswatches')->isEnabled()) {
// Check if swatches are enabled for product detail pages
// Note: Product detail swatches work independently of listing attribute configuration
if (Mage::getStoreConfigFlag(Mage_ConfigurableSwatches_Helper_Data::CONFIG_PATH_ENABLED)) {
if (Mage::helper('configurableswatches')->attrIsSwatchType($attribute->getProductAttribute())) {
$this->_init($jsonConfig);
return true;
Expand Down
18 changes: 11 additions & 7 deletions app/code/core/Mage/ConfigurableSwatches/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,18 @@ public function getSwatchesProductJs()
{
/** @var Mage_Catalog_Model_Product $product */
$product = Mage::registry('current_product');
if ($this->isEnabled() && $product) {
// Check if swatches are enabled and if there are detail page swatch attributes configured
// Note: Product detail swatches work independently of listing attribute configuration
if (Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLED) && $product) {
$configAttrs = $this->getSwatchAttributeIds();
/** @var Mage_Catalog_Model_Product_Type_Configurable $productType */
$productType = $product->getTypeInstance(true);
$configurableAttributes = $productType->getConfigurableAttributesAsArray($product);
foreach ($configurableAttributes as $configurableAttribute) {
if (in_array($configurableAttribute['attribute_id'], $configAttrs)) {
return 'js/configurableswatches/swatches-product.js';
if ($configAttrs !== []) {
/** @var Mage_Catalog_Model_Product_Type_Configurable $productType */
$productType = $product->getTypeInstance(true);
$configurableAttributes = $productType->getConfigurableAttributesAsArray($product);
foreach ($configurableAttributes as $configurableAttribute) {
if (in_array($configurableAttribute['attribute_id'], $configAttrs)) {
return 'js/configurableswatches/swatches-product.js';
}
}
}
}
Expand Down
Loading