2

There is a callout phtml file called in my right sidebar (let's call it attribute.phtml), on the product page.

I'm trying to show the attribute value in that callout.

The attribute is a drop down, so it should be

<?php echo $_product->getAttributeText('attributecode'); ?>

But I am missing something before that, I'm wondering how can I load it for the current product ? Note: this is not inside list or view , it's in template/callouts . I'm stuck, any help would be really appreciated right now...

2

The product should be available from the registry:

$_product = Mage::registry('current_product');

You should then be able to pull any required attributes straight out of it:

echo $_product->getAttributeText('attributecode');
|improve this answer|||||
0

Try adding this before your code:

<?php $_product = $this->getProduct(); ?>

You should then be able to call things based on product attributes... (here's an example that creates a shipping price callout based on product weight and price - this actually calls static blocks that have been created via Magento's adminhtml)

<?php if ($_product->getweight() > "155.0000" && $_product->getweight() < "187.0000"): ?>
  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('flat50')->toHtml() ?>
<?php elseif ($_product->getweight() > "186.0000" && $_product->getweight() < "208.0000"): ?>
  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('flat100')->toHtml() ?>
<?php elseif ($_product->getweight() < "156.0000" && $_product->getPrice() > "39.00"): ?>
  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('fship')->toHtml() ?>
<?php endif; ?>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.