0

I want to echo Meta description which will also pull the name of the product.

So far I have:

<?php echo '<meta name="xxx" />' ?>

I want the "xxx" to be the product name but unsure of how to do this.

I have tried this:

<?php echo '<meta name="description" content="'.$_helper->productAttribute($_product, $_product->getName(), 'name').'" />' ?>

this is clearly wrong :(

1 Answer 1

0

To get product details in head.phtml follow below comment

// Get product name
if($currentProduct = Mage::registry('current_product')) {
     $currentProduct->getName();
}
2
  • Be sure to check whether Mage::registry('current_product) exists at all, otherwise, might generate exceptions of calling method on non-object.
    – Prateek
    Nov 27, 2015 at 13:03
  • It works great. thank you :) the ; at the end through me off, but I removed it and it works fine. Nov 27, 2015 at 13:11

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.