在我的要求我需要设置类别页标题属性作为我的类别页标题,但对于我的一些不幸,它不是如我所料设置检查的Magento维基他们是它应该...Magento:如何获得页面标题属性(元标题)作为html页标题
我已经获得当前分类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:保护] => catalog_category [_eventObject:保护] =>类别[_cacheTag:保护] => catalog_category [_useFlatResource:protected] => [_designAttributes:Mage_Catalog_Model_Category:private] => Array([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] => Array([meta_title] => HP喷墨打印机墨盒| Trendsetter [name] => HP Inkjet [url_key] => hp-inkjets [url_path] => printer-consumables/hp/hp-inkjets [is_active] => 1 [available_sort_by] =>)[_storeValuesFlags:protected] => Array ([meta_title] => 1 [name] => 1 [url_key] => 1 [url_path] => 1 [is_active] => 1 [available_sort_by] => 1)[_lockedAttributes:protected] => Array()[_DeDeteable :保护] => 1 [_isReadonly:保护] => [_resourceName:保护] =>目录/类别[_resource:保护] => [_resourceCollectionName:保护] =>目录/ category_collection [_dataSaveAllowed:保护] => 1 [_isObjectNew :protected] => [_data:protected] => Array([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 [position] => 248 [level] => 2 [children_count] => 0 [名称] => HP Inkjet [display_mode] => PRODUCTS [meta_title] => HP Inkjet [url_key] => hp-inkjets [url_path] => printer-consumables/hp/hp-in kjets [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] => Array([entity_id] => 261 [entity_type_id] => 3 [ 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 [position] => 248 [level] => 2 [children_count] => 0 [name] => HP Inkjet [display_mode] => PRODUCTS [meta_title] => HP Inkjet [url_key] => hp- inkjet [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] => HP喷墨打印机墨盒[meta_description] =>高质量HP打印机墨盒和墨盒以极低的价格。[custom_design_from] => [custom_design_to] => [filter_price_range] =>)[_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => Array()[_syncFieldsMap:protected ] =>阵列())
并试图
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 [/ color] [/ color] [/ size] [/ size] [/ size] [/ size] [/ size] [/ size] [/ url] > 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_app ly_to_products] => 0 [meta_keywords] =>惠普喷墨打印机墨盒[meta_description] =>高质量惠普打印机墨盒和墨盒以极低的价格。 )惠普喷墨打印机
你试过吗? $ head = $ this-> getLayout() - > getBlock('head')){ $ head-> setTitle(“Your Category Title”); } – 2013-02-26 16:49:53
@chapagain非常感谢您的建议,但这就像我硬编码我需要从类别对象中获取attr(meta_title)值的标题,以便我可以在setTitle方法中设置... – ravisoni 2013-02-27 04:53:27