Magento:如何将类别页面标题属性(元标题)作为html页面标题

时间:2013-02-26 12:27:21

标签: php magento

在我的要求中,我需要将类别页面标题属性设置为我的类别页面标题,但对于一些我的不幸,它没有按预期设置我已经检查了magento wiki它们应该是...

我尝试过获取当前的类别ID,然后将其加载到头文件中以获取meta_title属性

$current_id=  Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$catobj = Mage::getModel('catalog/category')->load($current_id);
print_r($catobj);
echo $catobj->getMetaTitle();

但$ catobj-> getMetaTitle()给出了类别名称而不是类别页面标题: - (

我也试过打印类别obj,看到类别meta_title就在那里

Mage_Catalog_Model_Category对象([_eventPrefix:protected] => catalog_category [_eventObject:protected] => category [_cacheTag:protected] => catalog_category [_useFlatResource:protected] => [_designAttributes:Mage_Catalog_Model_Category:private ] =>数组([0] => custom_design [1] => custom_design_from [2] => custom_design_to [3] => page_layout [4] => custom_layout_update [5] => custom_apply_to_products)[ _treeModel:protected] => [_defaultValues:protected] =>数组([meta_title] => HP Inkjet打印机墨盒| Trendsetter [name] => HP Inkjets [url_key] => hp-inkjets [url_path] = > printer-consumables / hp / hp-inkjets [is_active] => 1 [available_sort_by] =>)[_ storeValuesFlags:protected] =>数组([meta_title] => 1 [name] => 1 [ url_key] => 1 [url_path] => 1 [is_active] => 1 [available_sort_by] => 1)[_lockedAttributes:protected] =>数组()[_ isDeleteable:protected] => 1 [_isReadonly :PR “保护的] => [_resourceName:protected] =>目录/类别[_resource:protected] => [_resourceCollectionName:protected] => catalog / category_collection [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] =>数组([entity_id] => 261 [entity_type_id] => 3 [attribute_set_id] => 3 [parent_id] => 259 [created_at] => 2012-12-11 13:00:28 [updated_at] = > 2013-02-26 12:08:33 [path] => 1/13/520/259/261 [position] => 248 [level] => 2 [children_count] => 0 [name ] => HP Inkjets [display_mode] =>产品[meta_title] => HP Inkjets [url_key] => hp-inkjets [url_path] => printer-consumables / hp / hp-inkjets [custom_design] => ; [page_layout] => [is_active] => 1 [is_anchor] => 0 [include_in_menu] => 1 [landing_page] => [custom_use_parent_settings] => 0 [custom_apply_to_products] => 0 [available_sort_by ] => [description] => [meta_keywords] =>惠普喷墨打印机墨盒[meta_description] =>高品质惠普打印机墨水和墨盒,价格极低。[custom_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] =>)[_ hasDataChanges:protected] => [_origData:protected] =>数组([entity_id] => 261 [entity_type_id] => 3 [attribute_set_id] => 3 [parent_id] => 259 [created_at] => 2012-12-11 13:00:28 [updated_at] = > 2013-02-26 12:08:33 [path] => 1/13/520/259/261 [position] => 248 [level] => 2 [children_count] => 0 [name ] => HP Inkjets [display_mode] =>产品[meta_title] => HP Inkjets [url_key] => hp-inkjets [url_path] => printer-consumables / hp / hp-inkjets [custom_design] => ; [page_layout] => [is_active] => 1 [is_anchor] => 0 [include_in_menu] => 1 [landing_page] => [custom_use_parent_settings] => 0 [custom_apply_to_products] => 0 [available_sort_by ] => [description] => [meta_keywords] =>惠普喷墨打印机墨盒[meta_description] =>高品质惠普打印机墨水和墨盒,价格极低。[custom_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] =>)[_ idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => Array()[_ syncFieldsMap:protected] => Array())


并试过

echo $catobj->meta_title;


但这也给出了相同的类别名称 :-( 请帮忙。

我调试了类别obj

print_r($catobj->debug());

但这显示meta_title与名称相同但不是,它的不同......真的很烦人

数组([entity_id] => 261 [entity_type_id] => 3 [attribute_set_id] => 3 [parent_id] => 259 [created_at] => 2012-12-11 13:00 :28 [updated_at] => 2013-02-26 12:08:33 [路径] => 1/13/520/259/261 [位置] => 248 [等级] => 2 [children_count] => 0 [name] => HP Inkjets [display_mode] =>产品[meta_title] => HP Inkjets [url_key] => hp-inkjets [url_path] => printer-consumables / hp / hp- inkjets [is_active] => 1 [is_anchor] => 0 [include_in_menu] => 1 [custom_use_parent_settings] => 0 [custom_apply_to_products] => 0 [meta_keywords] =>惠普喷墨打印机墨盒[meta_description] = >高品质惠普打印机墨水和墨盒,价格极低。)惠普喷墨打印机

2 个答案:

答案 0 :(得分:0)

$ catgId =类别ID

$catSel = Mage::getModel('catalog/category')->load($catgId); 
            $catDesc = array(
            'id' => $catgId,
            'desc' => $catSel->getDescription(),
            'url-key' => $catSel->getUrl_key(),
            'title' => $catSel->getMetaTitle()
        );

答案 1 :(得分:-1)

通过互联网搜索后,我找到了解决我的问题的方法,商店组错了。 谢谢