[英]How to append sku in product title in Magento.?
I want to append sku in product title in Magento using php code.我想使用 php 代码在 Magento 的产品标题中附加 sku。 Can anyone please help me on that.
任何人都可以帮助我。
<?php
//set empty title
$title = '';
if ($_product = Mage::registry('current_product'))
{
$title = $_product->getName();
$pos = stripos($title);
$title = $this->getTitle();
}
?>
<title><?php echo $title; ?> | test</title>
Here is the working code for above question.这是上述问题的工作代码。
<?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();
}
?>
<title><?php echo $title; ?> | test</title>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.