I have this PHP code (found of Stackoverflow): This shows the available attributes on the catalog view page in Magento.
<?php if($_product->isConfigurable()): ?>
<?php //get attributes
$attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
<?php if(count($attributes)): ?>
<ul>
<?php foreach($attributes as $att): ?>
<?php $pAtt=$att->getProductAttribute();
//get the child products
$allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
$frontValues =array() ?>
<li><?php echo $pAtt->getFrontendLabel() ?>
<ul>
<?php foreach($allProducts as $p): ?>
<?php //check stock, status, ...
//do not show unsaleable options
if(!$p->isSaleable()) continue; ?>
<?php $out=$p->getAttributeText($pAtt->getName()); ?>
<?php $frontValues[$out]=$out; ?>
<?php endforeach ?>
<li><?php echo implode('</li><li>', $frontValues) ?></li>
</ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<?php endif ?>
But due to my theme i have to include this in a Helper file (data.php)
Could anyone help me convert this into a piece of code suitable for the data.php?
I tried to remove all <?php and ?>. But that doesn't work.