0

特定のカテゴリの下にテキストを表示したいと思います。そのために、カテゴリIDを取得したいと思います。以下に示すように、カテゴリ配列を top.phtml(カスタム デザイン) に出力しました。

<?php foreach ($this->getStoreCategories() as $_category): ?>

 print_r($_category);

上記の print_r の結果は以下のとおりです。以下のオブジェクトを解析して、entity_id (ここではその値は 1013) または名前 (ここでは「勝利のルックス」) を取得するにはどうすればよいですか。

Mage_Catalog_Model_Category Object
(
[_eventPrefix:protected] => catalog_category
[_eventObject:protected] => category
[_cacheTag:protected] => catalog_category
[_useFlatResource:protected] => 1
[_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
    (
    )

[_storeValuesFlags:protected] => Array
    (
    )

[_lockedAttributes:protected] => Array
    (
    )

[_isDeleteable:protected] => 1
[_isReadonly:protected] => 
[_resourceName:protected] => catalog/category_flat
[_resource:protected] => 
[_resourceCollectionName:protected] => catalog/category_flat_collection
[_dataSaveAllowed:protected] => 1
[_isObjectNew:protected] => 
[_data:protected] => Array
    (
        [entity_id] => 1013
        [name] => Winning Looks
        [path] => 1/2/1013
        [is_active] => 1
        [is_anchor] => 1
        [request_path] => winning-looks.html
        [id] => 1013
    )

[_hasDataChanges:protected] => 1
[_origData:protected] => 
[_idFieldName:protected] => entity_id
[_isDeleted:protected] => 
[_oldFieldsMap:protected] => Array
    (
    )

[_syncFieldsMap:protected] => Array
    (
    )

)
4

2 に答える 2

0

これを試して:

if ($_category->getId() == 1013){ //or $_category->getEntityId();
   //your magic code here
}
于 2013-10-24T10:25:08.310 に答える