Joomla trim a class - joomla

Hy everyone I got this code
<?php if($this->item->params->get('itemRelatedIntrotext')): ?>
<div class="itemRelIntrotext"><?php $new_string = substr($item->introtext, 0, 220); echo $new_string; ?></div>
<?php endif; ?>
is bringing introtext, but its bringing the text with all the html code
<p class="mmbodytext">Dentro del <strong>Plan Estratégico</strong> de la campaña y como una de las líneas de acción de la comunicación está el <strong>Marketing Online</strong>. Su función, educar una...</p>
When the text is called i need to remove class="mmbodytext" and from it

If you are searching for an easy way to remove all tags you could use strip_tags().
<?php echo substr(strip_tags($item->introtext), 0, 220); ?>
Reference: strip_tags

Just figure it out...
<?php if($this->item->params->get('itemRelatedIntrotext')): ?>
<div class="itemRelIntrotext"><?php $new_string = substr($item->introtext, 0, 220); ?>
<?php $string = $new_string;
$wordlist = array("mmbodytext","<strong>");
foreach ($wordlist as $word) {
$string =str_replace($word, '', $string);
}
echo $string;
?>
</div>
<?php endif; ?>

Related

How can i get manufacturer image in manucarturer page in opencart2.0.2.0?

I am using opencart version 2.0.2.0 and now i am trying to get image or image url in manufacturer page.
I have added the code in catalog/controller/product/manufacturer.php
$manufacturer_image = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id);
if($manufacturer_image){
$this->data['manufacturers_img'] = $this->model_tool_image->resize($manufacturer_image['image'], 120, 120);
}else{
$this->data['manufacturers_img'] = false;
}
and call it in catalog/view/theme/default/template/product/manufacturer_list.tpl
<div class="row">
<?php foreach ($manufacturers as $manufacturer) { ?>
<div class="col-sm-3"><?php echo $manufacturer['name']; ?>
<?php echo ($manufacturers_img) ? '<img src="'.$manufacturers_img.'" alt="'.$manufacturers.'" />' : $manufacturers ;?><br />
</div>
<?php } ?>
</div>
But it's getting error in my /index.php?route=product/manufacturer page
Notice: Undefined variable: manufacturers_img in
/data1/opencart-2.0.2.0/catalog/view/theme/default/template/product/manufacturer_list.tpl
on line 32Array
lets be clear ControllerProductManufacturer index() shows list and info() shows detail of the mfg,
//catalog/controller/product/manufacturer.php:46
Replace
$data['categories'][$key]['manufacturer'][] = array(
with
$manufacturer_image = $this->model_catalog_manufacturer->getManufacturer($result['manufacturer_id']);
if($manufacturer_image){
$mfg_img = $this->model_tool_image->resize($manufacturer_image['image'], 120, 120);
}else{
$mfg_img = false;
}
$data['categories'][$key]['manufacturer'][] = array(
'image'=>$mfg_img,
And in catalog/view/theme/default/template/product/manufacturer_list.tpl:30
inside loop
<?php if($manufacturer['image']):?>
<img src="<?php echo $manufacturer['image']; ?>" alt="<?php echo $manufacturer['name'];?>">
<?php endif;?>

Create multiple row product slider

I'm using magento and I have a new product slider on my homepage that shows the new products but it is only one row big and I want to decide if it's 2 rows or more on my homepage but i don't know what i need to change in the .phtml file so it is 2 rows instead of one.
If you go to parts2u.nl you can see what i mean underneath Nieuwe Artikelen that is the new product slider I'm talking about.
This is the code:
<?php
/**
*
*/
?>
<?php
$_productCollection = $this->getProductCollection();
?>
<?php if ($_productCollection && ($_collectionSize = $_productCollection->getSize())): ?>
<?php
$theme = $this->helper('fortis');
$helpLabels = $this->helper('fortis/labels');
$helpTemplate = $this->helper('fortis/template');
$helpImg = $this->helper('infortis/image');
$sliderClasses = '';
$gridClasses = '';
//Default image size
$imgWidth = 168;
$imgHeight = 168;
//Image aspect ratio
if ($theme->getCfg('category/aspect_ratio'))
{
$imgHeight = 0; //Height will be computed automatically (based on width) to keep the aspect ratio
}
//Basic slider block parameters
//--------------------------------------------------------------
$isResponsive = $this->getIsResponsive(); //param: is_responsive
$breakpoints = $this->getBreakpoints(); //param: breakpoints
$showItems = $this->getShowItems(); //param: show_products
if (!$showItems)
{
$showItems = 5; //IMPORTANT: set default number of visible products
}
//Slider timeout (if set: automatic slideshow)
$timeout = $this->getTimeout(); //param: timeout
if ($timeout === NULL) //Param not set
{
$timeout = intval($theme->getCfg('product_slider/timeout'));
}
else
{
$timeout = intval($timeout);
}
//Slider initial delay
$initDelay = intval($this->getInitDelay()); //param: init_delay
//Number of items that should move on animation
$move = $this->getMove(); //param: move
if ($move === NULL) //Param not set
{
$move = intval($theme->getCfg('product_slider/move_items'));
}
else
{
$move = intval($move);
}
//Additional slider classes
//--------------------------------------------------------------
if($isResponsive)
{
$sliderClasses .= ' itemslider-responsive';
}
if ($_collectionSize == 1)
{
$sliderClasses .= ' single-item';
}
//Additional grid classes
//--------------------------------------------------------------
//Size of grid elements
$size = $this->getSize(); //param: size
if ($size)
{
$gridClasses = ' ' . $size;
}
else
{
if ($showItems >= 8)
{
$gridClasses = ' size-xs';
}
elseif ($showItems >= 6)
{
$gridClasses = ' size-s';
}
}
//Align elements to the center
if ($this->getCentered()) //param: centered
{
$gridClasses .= ' centered';
}
//Set equal height for all items
if ($this->getEqualHeight()) //param: equal_height
{
$gridClasses .= ' equal-height';
}
?>
<h3 class="section-title padding-right"><?php echo $this->getBlockName(); ?></h3>
<div class="itemslider-wrapper new-itemslider-wrapper">
<div class="nav-wrapper gen-slider-arrows1 gen-slider-arrows1-pos-top-right"></div>
<div class="itemslider itemslider-horizontal<?php if($sliderClasses) echo $sliderClasses; ?>">
<ul class="slides products-grid<?php if($gridClasses) echo $gridClasses; ?>">
<?php foreach ($_productCollection->getItems() as $_product): ?>
<li class="item">
<div class="product-image-wrapper" style="max-width:<?php echo $imgWidth; ?>px;">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" class="product-image">
<img src="<?php echo $helpImg->getImg($_product, $imgWidth, $imgHeight, 'small_image'); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true); ?>" />
<?php if ($theme->getCfg('category/alt_image')): ?>
<?php echo $theme->getAltImgHtml($_product, $imgWidth, $imgHeight); ?>
<?php endif; ?>
<?php echo $helpLabels->getLabels($_product); //Product labels ?>
</a>
<?php //Add-to links
if ($theme->getCfg('category_grid/display_addtolinks') != 0
&& $theme->getCfg('category_grid/addtolinks_simple'))
{
if ($theme->getCfg('category_grid/display_addtolinks') == 1) //Display on hover
{
echo $helpTemplate->getCategoryAddtoLinksComplex_2(
$_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage visible-onhover');
}
else //Always display
{
echo $helpTemplate->getCategoryAddtoLinksComplex_2(
$_product, $this->getAddToCompareUrl($_product), 'addto-links-icons addto-onimage');
}
}
?>
</div> <!-- end: product-image-wrapper -->
<h3 class="product-name"><?php echo $this->escapeHtml($_product->getName()) ?></h3>
<?php echo $this->htmlEscape($_product->getSku()); ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php echo $this->getPriceHtml($_product, true, '-new') ?>
<div class="actions">
<?php if($_product->isSaleable()): ?>
<?php if ($this->getHideButton() == false): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<?php endif; ?>
<?php else: ?>
<?php if ($this->getHideButton() == false): ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php endif; ?>
<?php //Add-to links
if ($theme->getCfg('category_grid/display_addtolinks') != 0 && !$theme->getCfg('category_grid/addtolinks_simple'))
{
if ($theme->getCfg('category_grid/display_addtolinks') == 1) //Display on hover
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right addto-texticons display-onhover');
else //Always display
echo $helpTemplate->getCategoryAddtoLinks($_product, $this->getAddToCompareUrl($_product), 'addto-gaps-right addto-texticons');
}
?>
</div>
</li>
<?php endforeach; ?>
</ul> <!-- end: slides -->
</div> <!-- end: itemslider -->
</div> <!-- end: new-itemslider-wrapper -->
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$('.new-itemslider-wrapper .itemslider').flexslider({
namespace: "",
animation: "slide",
easing: "easeInQuart",
<?php if ($timeout): ?>
slideshowSpeed: <?php echo $timeout; ?>,
animationLoop: true,
<?php else: ?>
slideshow: false,
animationLoop: false,
<?php endif; ?>
<?php if ($initDelay): ?>
initDelay: <?php echo $initDelay; ?>,
<?php endif; ?>
<?php if ($speed = intval($theme->getCfg('product_slider/speed'))): ?>
animationSpeed: <?php echo $speed; ?>,
<?php endif; ?>
pauseOnHover: true,
controlNav: false,
controlsContainer: ".new-itemslider-wrapper .nav-wrapper",
itemWidth: 188,
<?php if ($showItems): ?>
minItems: <?php echo $showItems; ?>,
maxItems: <?php echo $showItems; ?>,
<?php endif; ?>
move: <?php echo $move; ?>
})
<?php if ($breakpoints): ?>
.data("breakpoints", [ <?php echo $breakpoints; ?> ] )
<?php elseif ($showItems): ?>
.data("showItems", <?php echo $showItems; ?> )
<?php endif; ?>
; //IMPORTANT: don't remove semicolon!
});
//]]>
</script>
<?php endif; ?>
This seems like an incredibly convoluted implementation. I recommend that you seriously invest some time building your own slider rather than attempting to hack this to work the way you desire. Super cereal.

Strange replace on magento URL

For some reason, only on view-mode icons on the product list, the "?" of the urls are replaced to "#21". Ex.: "#%21mode=list"
Somebody can help me?
Some code:
app/design/frontend/default/themename/template/catalog/product/list/toolbar.phtml
<?php if( $this->isEnabledViewSwitcher() ): ?>
<p class="view-mode">
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php foreach ($this->getModes() as $_code=>$_label): ?>
<?php if($this->isModeActive($_code)): ?>
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>
<?php else: ?>
<?php echo $_label ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</p>
<?php endif; ?>
app/code//core/Mage/Catalog/Block/Product/List/Toolbar.php
public function getModeUrl($mode)
{
return $this->getPagerUrl( array($this->getModeVarName()=>$mode, $this->getPageVarName() => null) );
}
and...
public function getPagerUrl($params=array())
{
$urlParams = array();
$urlParams['_current'] = true;
$urlParams['_escape'] = true; // I already tried set false, but didn't helps
$urlParams['_use_rewrite'] = true;
$urlParams['_query'] = $params;
return $this->getUrl('*/*/*', $urlParams); // I also tried not use the getUrl and concat the querystring, strangely the replace still happends...
}
I couldn't find the problem, but I make a dirt solution:
<?php echo str_replace('#%21', '&', $this->getModeUrl($_code)); ?>
I wish somebody find a better solution :)

How to make Installments on product page get Final or SpecialPrice instead of GrantTotal?

Maybe someone can help me on this one. I want to insert a dropdown installments on product page, and must show the price numbers with 2 decimals, for example: R$ 300,00 instead of R$ 300,0000. Thank you!
This is the code that i have and tried to modify it but with no success:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="dadoscartaoopc">Parcelamento no Cartão de Crédito:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . $v['valor'] . " | Total: R$ " .$v['total']."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>
Printscreen of the actual dropdown: http://postimg.org/image/pokqf6xxj/03a4fda4/
Solution:
<?php
$standad = Mage::getSingleton('moip/standard');
$api = Mage::getSingleton('moip/api');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('o2ti_moip/css/formulario.css'); ?> "media="all">
<?php
$_product = $this->getProduct( );
$_coreHelper = $this->helper('core');
?>
<?php if ($standad->getConfigData('parcelamento')): ?>
<label id="parcelamentoproduto">PARCELAMENTO NO CARTÃO DE CRÉDITO:</label>
<select name="payment[credito_parcelamento]" id="credito_parcelamentoproduto" >
<?php
$parcelamento = $api->getParcelamento($_product->getFinalPrice());
foreach ($parcelamento as $k => $v): ?>
<option value="<?php echo $k ?>"><?php echo $k . "x R$ " . number_format($v['valor'],2,',',' ') . " ---------- Total: R$ " .number_format($v['total'],2,',',' ')."" ?></option>
<?php endforeach; ?>
</select>
<?php endif; ?>
<div id="addparcelas">
<?php
$standard = Mage::getSingleton('moip/standard');
$parcelamento = $standard->getInfoParcelamento();
if ($parcelamento['juros1'] == 0)
{
echo "<div id=\"addparcelasdesc\"> Sem juros até ".$parcelamento['ate1']." parcelas,</div>";
if ($parcelamento['ate1'] < 13)
{
echo "após juros de 1,99% ao mês.";
}
}
if ($parcelamento['juros1'] >= "1.99")
{
echo "Com juros de ".$parcelamento['juros1']." ao mês.";
}
?>
</div>

Change the text "Choose an option..." on Magento product page

I created a configurable product, it has three option: color, size and style.
Now in product page, each option has the default text "Choose an Option..." in dropdown, but I want the text should be "Select color", "Select size" and "Select style".
I edited function getJsonConfig() in app\code\core\Mage\Catalog\Block\View\Type\Configurable.php
From:
'chooseText' => Mage::helper('catalog')->__('Choose an Option...'),
To:
'chooseText' => ('Select ').$attribute->getLabel(),
And edit line 39 of the file frontend/base/default/template/catalog/product/view/type/options/configurable.phtml to:
<option><?php echo $this->__('Select ') ?><?php echo $_attribute->getLabel() ?></option>
But the result is not good, it alway show the text "Choose style" in three options.
Please give me a hint for this issue, thank you very much!
My version of the same problem. You need to change only template
catalog/product/view/type/options/configurable.phtml:
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<?php $chooseText = $this->__('Select %s', $_attribute->getLabel()); ?>
<select data-choose-text="<?php echo $chooseText; ?>" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $chooseText; ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
Product.ConfigDefaultText = new Class.create(Product.Config, {
fillSelect: function($super, element) {
$super(element);
var chooseDefaultText = element.getAttribute('data-choose-text');
$(element).options[0] = new Option(chooseDefaultText, '');
}
});
var spConfig = new Product.ConfigDefaultText(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>
Note (extracted from comments)
If the selected default value happens not to be "Select %s", replace
$(element).options[0] = new Option(chooseDefaultText, '');
with
$(element).options[0].innerHTML = chooseDefaultText;
I was looking for a more simple way to do this. I didn't want to extend any core files or muck around with extending JavaScript. Instead I parsed the settings JSON, updated the chooseText setting, and converted back to JSON:
/~theme/default/template/catalog/product/view/type/options/configurable.phtml
<?php
$jsonConfig = json_decode($this->getJsonConfig());
$jsonConfig->chooseText = 'Select..';
?>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo json_encode($jsonConfig); ?>);
</script>
More information and further examples here.
The only way I think is just to modify the javascript class that populates that dropdowns. As we can see in frontend/base/default/template/catalog/product/view/type/options/configurable.phtml that class is:
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
</script>
The file with needed class located in js/varien/product.js
The place where first <option> tag is set up is:
fillSelect: function(element){
var attributeId = element.id.replace(/[a-z]*/, '');
var options = this.getAttributeOptions(attributeId);
this.clearSelect(element);
element.options[0] = new Option(this.config.chooseText, '');
...
The variable chooseText used there on line 368. This variable was created in function getJsonConfig() in app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php (you was digging the right way). You need to modify the javascript that I described earlier to achive what you need (based on var attributeId you can assign options with different text to elements you need)
If you only change file configurable.js
It will only change first select when page load
So I must change template file
Get attached file for test.(I just write it to an small extension)
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_attributeId = $_attribute->getAttributeId();
$_attributeInfo = Mage::getModel('eav/entity_attribute')->load($_attributeId);
$_attributeLabel = str_replace(' ','-',strtolower($_attributeInfo->getFrontendLabel()));
?>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select kevin-black-<?php echo $_attributeLabel;?>">
<option><?php echo $_attributeInfo->getFrontendLabel() ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
//kevin.qazware#gmail.com Change Text follow attribute Label
function changeFristText(){
<?php foreach($_attributes as $_attribute): ?>
<?php
$_attributeId = $_attribute->getAttributeId();
$_attributeInfo = Mage::getModel('eav/entity_attribute')->load($_attributeId);
?>
var label = '<?php echo $_attributeInfo->getFrontendLabel();?>';
$$('select.kevin-black-'+label).each(function(elem){
var options = elem.childElements();
options[0].update(label);
});
<?php endforeach;?>
}
</script>
<?php endif;?>
in file : js/varien/configurable.js replace line 171 = element.options[0] = new Option(element.config.label, ‘’);
It for all attribute set .
simplest answer:
replace js/varien/configurable.js line 172
element.options[0].innerHTML = 'Choose ' + this.config.attributes[attributeId].label;
I extended class Product.Config (method fillselect) by these code:
fillSelect: function(element){
var attributeId = element.id.replace(/[a-z]*/, '');
var options = this.getAttributeOptions(attributeId);
this.clearSelect(element);
element.options[0] = new Option('Select '+element.config.label,'');
........
It's ok!
<script type="text/javascript">
<?php
$jsonConfig = $this->getJsonConfig();
$jsonConfig = str_replace("Choose an Option...", "Select Size", $jsonConfig);
?>
var spConfig = new Product.Config(<?php echo $jsonConfig; ?>);
</script>
file catalog/product/view/type/options/configurable.phml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_attributeId = $_attribute->getAttributeId();
$_attributeInfo = Mage::getModel('eav/entity_attribute')->load($_attributeId);
$_attributeLabel = str_replace(' ','-',strtolower($_attributeInfo->getFrontendLabel()));
?>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select kevin-black-<?php echo $_attributeLabel;?>">
<option><?php echo $this->__('Select '.$_attributeLabel) ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
//Change Text follow attribute Label
function changeFristText(){
<?php foreach($_attributes as $_attribute): ?>
<?php
$_attributeId = $_attribute->getAttributeId();
$_attributeInfo = Mage::getModel('eav/entity_attribute')->load($_attributeId);
$_attributeLabel = str_replace(' ','-',strtolower($_attributeInfo->getFrontendLabel()));
?>
var label = '<?php echo $_attributeLabel;?>';
$$('select.kevin-black-'+label).each(function(elem){
var options = elem.childElements();
options[0].update('Select ' + label);
});
<?php endforeach;?>
}
</script>
<?php endif;?>
and add one line changeFristText(); after line 171 (element.options[0] = new Option(this.config.chooseText, '');) in file js/varien/configurable.js
It for all attribute set.
This worked for me on CE 1.8.1. It's based off Shein's answer, and addresses the wrong option getting selected on load. I basically just copied/pasted the Product.Config.fillSelect() method from /js/varien/product.js. Within the pasted code I changed:
element.options[0].innerHTML = this.config.chooseText;
to
element.options[0].innerHTML = element.config.label;
This allows keeping product.js unmodified, and just override the method. The only drawback is any future core updates to that method will need migrating.
Since the new code just gets the "label" setting, the data-choose-text attribute on isn't needed on the select tag
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $_attribute->getLabel() ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
Product.ConfigDefaultText = new Class.create(Product.Config, {
fillSelect: function (element) {
var attributeId = element.id.replace(/[a-z]*/, '');
var options = this.getAttributeOptions(attributeId);
this.clearSelect(element);
element.options[0] = new Option('', '');
element.options[0].innerHTML = element.config.label;
var prevConfig = false;
if (element.prevSetting) {
prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex];
}
if (options) {
var index = 1;
for (var i = 0; i < options.length; i++) {
var allowedProducts = [];
if (prevConfig) {
for (var j = 0; j < options[i].products.length; j++) {
if (prevConfig.config.allowedProducts
&& prevConfig.config.allowedProducts.indexOf(options[i].products[j]) > -1) {
allowedProducts.push(options[i].products[j]);
}
}
} else {
allowedProducts = options[i].products.clone();
}
if (allowedProducts.size() > 0) {
options[i].allowedProducts = allowedProducts;
element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
element.options[index].config = options[i];
index++;
}
}
}
}
});
var spConfig = new Product.ConfigDefaultText(<?php echo $this->getJsonConfig() ?>);
</script>
<?php endif;?>

Resources