简体   繁体   English

如何在 Magento 的产品标题中附加 sku。?

[英]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.

相关问题 如何在 Magento 的产品名称中附加 Sku。? - How to append Sku in product name in Magento.? 如何在 Magento 的元描述中附加 sku。? - How to append sku in meta description in Magento.? 马杰托。 如何使用自定义选项以编程方式在购物车中添加简单产品 - Magento. How to add simple product in cart programmatically with custom options Magento产品网址显示制造商和SKU,我希望它显示标题 - Magento product URL shows Manufacturer and SKU, I want it to show the title Magento-如何通过Sku将产品分配给Category? - Magento - How to assign product to Category by Sku? Magento。 如何以编程方式为自定义选项(复选框)设置数据并在购物车中添加简单产品? - Magento. How to set data for custom options(checkbox) programatically and add simple product in cart? 如何在Magento中以编程方式设置捆绑产品的Sku类型和价格类型? - How to set Sku Type & Price Type of Bundle Product programmatically in Magento? Magento 2如何从目录规则中排除可配置产品sku - Magento 2 How to exclude configurable product sku from catalog rule 如何在Magento 1.7中为可配置产品中的每个属性值设置SKU? - How to set SKU for each attribute value in configurable product in Magento 1.7? 如何在收到的订单页面和电子邮件订单中显示带有产品标题的 SKU - How to Show SKU with product title in Order received page and Email order
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM