2012-04-19 16 views
0

カテゴリのパラメータを基にしてカテゴリナビゲーショントップをソートする必要があります。カテゴリのパラメータがordenされ、これは、次のスクリプトでMagentoのに追加されます。Magentoカテゴリトップメニューを並べ替える方法

$installer = $this; 
$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 
$installer->startSetup(); 

$setup->addAttribute('catalog_category', 'sort', array(
    'group'   => 'General', 
    'input'   => 'text', 
    'type'   => 'varchar', 
    'label'   => 'sort', 
    'backend'  => '', 
    'visible'  => 1, 
    'required'  => 0, 
    'user_defined' => 1, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
)); 

$installer->endSetup(); 

しかし、私は、この属性のベースでどのようなものを知っているドント。 あなたがMage_Catalog_Block_Navigationが表示された場合は、これは私がオブジェクトのこのタイプを並べ替える方法をドントVarien_Data_Tree_Node_Collectionオブジェクト型である

/** 
* Get catagories of current store 
* 
* @return Varien_Data_Tree_Node_Collection 
*/ 
public function getStoreCategories() 
{ 
    $helper = Mage::helper('catalog/category'); 
    return $helper->getStoreCategories(); 
} 

次の機能を見ることができ、私はのベースにカテゴリと順序本のGETコレクションで考えます私のカスタム属性、あなたが

return $helper->getStoreCategories(false,true); 

に真のパラメータを渡すことができますことを考えると取得し、入力しMage_Catalog_Model_Resource_Eav_Mysql4_Category_Collectionをこの順番を試してみてください。

この問題のアイデアは何ですか? ありがとうございます

答えて

0

このソリューションはまだ試しましたか?

http://www.netismine.com/magento/sort-categories-in-header-menu

+0

私は私がVarien_Data_Tree_Node_Collectionオブジェクトにこのカスタム属性を追加することができますどのように、ベースで並べ替えカスタム属性をしたいです? Mage_Catalog_Model_Resource_Eav_Mysql4_Categoryコレクションがある場合、_load_beforeイベントでこれを行うことができます。 Varien_Data _...でこれをどうやって作ったのか分かりません。 – davidselo

関連する問題