skip to Main Content

I want to append sku in meta description in Magento using php code. Can anyone please help me on that.

<?php 
//set empty title
$title = ''; 
if ($_product = Mage::registry('current_product')) 
{ 
$title = $_product->getName();
$pos = stripos($title);
if($pos === false )
{
$title = $this->getTitle();
}
?>
<meta name="description" content="<?php echo $title?>.Wide range of shipping destinations. Call us now for more info about our products: 01202 600596. Contact us to discuss our returns policy"/>

2

Answers


  1. Chosen as BEST ANSWER

    After lots of digging into this I found the solution and that is working fine.

    <?php 
    //set empty title
    $title = ''; 
    if ($_product = Mage::registry('current_product')) 
    { 
    $title = $_product->getName();
    $sku = $_product->getSku();
    $pos = stripos($title, $sku);
    if($pos === false )
    {
    //no sku already - append now
    $title.= ' - ' . $sku;
    }
    }
    else
    { 
    $title = $this->getTitle();
    }
    ?>
    <meta name="description" content="<?php echo $title?>.Wide range of shipping destinations. Call us now for more info about our products: 01202 600596. Contact us to discuss our returns policy"/>
    

  2. Export products (System>Import/Export) and that gives you the csv structure. You can delete all columns but keep sku, store and meta description. Put the data you want into the csv. Save it as UTF-8 (don’t use MS excel!) and import (System>Import/Export) replacing existing data. Make sure you try this on a dev site first and use the ‘check data’ function to make sure everything is correct before importing. Good luck.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search