回答
由於產品已經有一個附加MetaKeyword值,你可以使用一個觀察者悄悄地延長該值。該方法不涉及延伸的核心類
試試這個:
/app/code/local/YourCompany/YourModule/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<YourCompany_YourModule>
<version>1.0.0</version>
</YourCompany_YourModule>
</modules>
<global>
<models>
<YourCompany_YourModule>
<class>YourCompany_YourModule_Model</class>
</YourCompany_YourModule>
</models>
</global>
<frontend>
<events>
<catalog_controller_product_view>
<observers>
<YourCompany_YourModule>
<class>YourCompany_YourModule/Observer</class>
<method>productView</method>
</YourCompany_YourModule>
</observers>
</catalog_controller_product_view>
</events>
</frontend>
</config>
/應用/代碼/本地/YourCompany/YourModule/Model/Observer.php
<?php
class YourCompany_YourModule_Model_Observer
{
public function productView(Varien_Event_Observer $observer)
{
$product = $observer->getEvent()->getProduct();
/* @var $product Mage_Catalog_Model_Product */
if ($product) {
$keywords = $product->getMetaKeyword();
// Add the product name
$keywords = ' ' . $product->getName();
// Add the category name
$currentCategory = Mage::registry('current_category');
if ($currentCategory && $currentCategory instanceof Mage_Catalog_Model_Category) {
$keywords = ' ' . $currentCategory->getName();
}
$product->setMetaKeyword($keywords);
}
}
}
您是否想了解產品詳細頁面?如果是指非常簡單
轉到您的具體產品頁面,應該有標籤「元信息」。在這裏,你可以添加
Meta Title, Meta Keywords, Meta Description
我想他想動態添加 –
如何檢查我的所有類別是否有元標記? – Rathinam
你不得不重新改寫Mage_Catalog_Block_Product_View類,尤其是__preparelayout()方法。
只需添加以下代碼_prepareLayout方法將覆蓋:
protected function _prepareLayout()
{
$currentCategory = Mage::registry('current_category'); // For accessing current category information
$product = $this->getProduct();
if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle("Whatever you want here");
$product->setMetaKeyword("whatever, keywords, you, want, here");
$product->setMetaDescription("Whatever description you want here);
}
return parent::_prepareLayout();
}
您設置的metakeyword和metadescription它會再次被父類被覆蓋在它上面定律描述的方式,否則是很重要的( ES)。
問候, 肯尼
- 1. 動態meta(關鍵字,說明)
- 2. Magento使用meta關鍵字搜索
- 3. 如何在magento中按產品關鍵字(meta關鍵字)獲取相關產品?
- 4. Moodle Meta關鍵字
- 5. meta關鍵字CHARACTERSET
- 6. 從網頁中提取Meta關鍵字?
- 7. 動態meta描述和關鍵字 - WordPress的PHP
- 8. Javascript - 獲取Meta關鍵字和如果Non不會中斷Bookmarklet
- 9. Magento的meta關鍵字標籤不顯示
- 10. 循環遍歷Magento類別,Meta關鍵字和描述
- 11. 類別meta關鍵字,描述問題在Magento
- 12. PHP變換文字meta關鍵字
- 13. MVC 3 Razor Meta描述/關鍵字
- 14. 有多少關鍵字適合META關鍵字標籤?
- 15. 與動態關鍵字
- 16. .NET 4.0 - 「動態」關鍵字
- 17. 動態關鍵字示例
- 18. 博客上的變量Meta關鍵字
- 19. 是Meta關鍵字區分大小寫?
- 20. 如何在谷歌搜索引擎中使用meta關鍵字獲取鏈接頁面關鍵字?
- 21. JavaScript - 從動態鍵/值獲取動態鍵/值的值
- 22. 從html內容中生成META關鍵字
- 23. 動態名關鍵
- 24. 檢索描述和關鍵字meta標籤在php
- 25. 獲取單META NAME
- 26. 對於動態關鍵字沒有intellisense?
- 27. 動態LINQ中的SQL Like關鍵字
- 28. 關鍵字 「汽車」 C++和 「動態」 C#
- 29. 動態更改組關鍵字
- 30. 動態關鍵字啓用「也許」monad?
僅供參考,元關鍵詞標籤對您的網頁排名沒有影響。沒有主要的搜索引擎使用它們了。 –