4

Created a custom attribute and assigned it to all attribute set for Magento 1.9 Sample Data. I have set Visible on Product View page and Product Listing page to YES.

attribute

Assigned attribute value to product as shown below

Product Points

The attribute value is shown under additional information on product details page. How do I show it as shown in below image using layout. Which block do I need to change ? My extension resides under app/code/local/

points details

1
  • does solve your problem
    – Gem
    Nov 21, 2016 at 14:18

2 Answers 2

1

I'm confused a bit. You state you created a custom attribute. You then speak of using an extension in app/code/local. Why do you need an extension for placing an attribute?

Have you considered adding to /app/design/frontend/yourtheme/default/template/catalog/product/view.phtml something like this?

<p>YOU WILL EARN <?php echo $_product->getAttributeText('customer_product_points') ?> POINTS FOR PURCHASING THIS PRODUCT.</p>
2
  • I am able to display the attribute but not at the specified location. Rest is done. Jan 4, 2016 at 5:41
  • Make sure <?php $_product = $this->getProduct(); ?> appears in the beginning of the document.
    – Scot
    Jan 7, 2016 at 1:08
1

Add following code to inject custom attribute on Product Detail Page.

Add following code in your module.xml of frontend.

<catalog_product_view>
    <reference name="product.info.addtocart">
        <block type="core/text_list" name="block.view">
        <block type="module/block" name="block.cart.view" as ="blockview" template="Namespace/Module/cart/view.phtml"/> 
        </block>
    </reference>
</catalog_product_view>

Create file: app\design\frontend\base\default\template\namespace\module\cart\view.phtml

And add following code in view.phtml -

<?php
$_proId= Mage::registry('current_product')->getId();
$_product= Mage::getModel('catalog/product')->load($_proId);
$CustomAttribute= $_product->getData('custom_attribute');
echo $CustomAttribute;    
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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