1

I'm using the "product.info.extrahint" reference in my module layout to add my block and in the block template i'm calling a product attribute ('pticks') but for some reason its not working.

My module layout

<?xml version="1.0"?>
<layout version="0.1.0">
    <catalog_product_view>
    <reference name="product.info.extrahint">
    <block type="core/template" as="productticks_productticks" template="productticks/productticks.phtml" />
    </reference>
    </catalog_product_view>
</layout>

Module template file

<?php $_helper = Mage::helper('catalog/output'); ?>
<div><?php echo $_product->getData('pticks');?></div>

The template is loaded but the attribute will not show. I'm getting the error Call to a member function getData() on null which i cant understand because this is on the product page and its clearly an object because the same code works fine on view.phtml.

Why will the attribute not load in my template file referenced in product.info.extrahint. What am i missing?

  • What happens if you replace getAttributeText('pticks') with getPticks() ? – Raphael at Digital Pianism Jun 5 '16 at 13:07
  • Thanks tried that but no attribute value shown and getting error "Call to a member function getPticks() on null" – markbarabus Jun 5 '16 at 14:24
2

That means your $_product is not an object for some reason.

I suspect it's your layout.

Replace this

<block type="core/template" as="productticks_productticks" template="productticks/productticks.phtml" />

To

<block type="catalog/product_view" as="productticks_productticks" template="productticks/productticks.phtml" />

And you should have $_product = $this->getProduct() in your template.

Your productticks/productticks.phtml's block type is core/template which doesn't reference product object, that is why your $product is null.

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.