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

  • does solve your problem – Gem Nov 21 '16 at 14:18
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>
  • I am able to display the attribute but not at the specified location. Rest is done. – Slimshadddyyy Jan 4 '16 at 5:41
  • Make sure <?php $_product = $this->getProduct(); ?> appears in the beginning of the document. – Scot Jan 7 '16 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, privacy policy and cookie policy

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