Adam Allen Adam Allen - 1 year ago 95
PHP Question

Displaying an attribute in a tab

I have been trying to display a product attribute that i created called “PDF” in a tab. I tried to re-use the code that had been used to get the product description but change it to reference my new Attribute, well so i thought.

This is the code i used:

The attribute code is: pdf
Admin title is: PDF

<?php $_pdf = $this->getProduct()->getPDF(); ?>
<?php if ($_pdf): ?>
<h2><?php echo $this->__('PDF') ?></h2>
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_pdf, 'pdf') ?>
<?php endif; ?>

I maybe no where near where i have to be but i am new to magento and new to PHP as well.

I dont want to have to use any extensions if possible.

If you can fix this for me you will be a god! thanks in advance for any help.

Answer Source

You are using $this->getProduct()->getPDF() when you should be using $this->getProduct()->getPdf(). Magento camel cases attribute names for its magic methods.

You could also use $this->getProduct()->getData('pdf').

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download