在view. php中获取magento头部描述


Get magento header description in schema Product description in view.phtml

在标题中,我有以下代码用于元描述。

<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />

我试图将此描述作为我的模式产品描述,如下所示在view.pthml文件

<meta itemprop="description" name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />

但是"Description"在google富片段工具(GRST)上显示为空白

当我在标题中包含并标记元描述时。phtml文件

<meta itemprop="description" name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />

带有<span itemscope itemtype="Http://Schema.Org/Product" >的描述显示在GRST上,但当然会破坏view. php上的其他产品项类型。

那么我如何获得标题中的描述以在view. php中显示为模式产品描述呢?

注意:没有使用默认的元描述(空白),一个名为creare SEO的扩展根据属性创建元描述。

这就是解决问题的方法

<?php $headBlock = $this->getLayout()->getBlock('head'); echo $description=$headBlock->getDescription(); ?>" />

感谢Amit Bera,参考文章