0

在我的要求中,我需要将类别页面标题属性设置为我的类别页面标题,但对于某些我的不幸,它没有按预期设置我已经检查了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 在那里

[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_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 [位置] => 248 [级别] => 2 [children_count] => 0 [name] => HP Inkjets [display_mode] => PRODUCTS [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] => HP 喷墨打印机墨盒 [meta_description] => 高以极低的价格提供优质的 HP 打印机墨水和墨盒。[custom_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] => ) [_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => 数组 () [_syncFieldsMap:protected ] => 数组 ( ) ) 打印机耗材/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_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] => ) [_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => 数组 () [_syncFieldsMap:protected ] => 数组 ( ) ) 打印机耗材/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_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] => ) [_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => 数组 () [_syncFieldsMap:protected ] => 数组 ( ) ) [custom_use_parent_settings] => 0 [custom_apply_to_products] => 0 [available_sort_by] => [description] => [meta_keywords] => HP 喷墨打印机墨盒 [meta_description] => 以极低的价格提供高品质的 HP 打印机墨水和墨盒。[custom_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] => ) [_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => 数组 () [_syncFieldsMap:protected ] => 数组 ( ) ) [custom_use_parent_settings] => 0 [custom_apply_to_products] => 0 [available_sort_by] => [description] => [meta_keywords] => HP 喷墨打印机墨盒 [meta_description] => 以极低的价格提供高品质的 HP 打印机墨水和墨盒。[custom_layout_update] => [custom_design_from] => [custom_design_to] => [filter_price_range] => ) [_idFieldName:protected] => entity_id [_isDeleted:protected] => [_oldFieldsMap:protected] => 数组 () [_syncFieldsMap:protected ] => 数组 ( ) )


并尝试过

echo $catobj->meta_title;


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

我已经调试了类别 obj

print_r($catobj->debug());

但这表明 meta_title 与 name 相同但它不是,它不同.. 真的很烦人

数组( [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] => PRODUCTS [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] => HP 喷墨打印机墨盒 [meta_description] => 以极低的价格提供高品质 HP 打印机墨水和墨盒。) HP Inkjets

4

2 回答 2

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()
        );
于 2013-08-29T06:23:45.157 回答
-1

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

于 2013-03-01T05:47:28.343 回答