類別和子類別i已經創建自定義模塊,其用於的Magento它由類別和子類別的表中的問題,現在我想顯示以下 第1類 子目錄1 子目錄2 子類別3 類別2 類別1 子目錄2 子目錄3 類別3 子目錄1 子目錄2 子目錄3如何顯示在Magento
我的代碼是 $集合=馬GE :: getModel( 'supportportal/supportportal') - > getCollection(); // - > addFieldToFilter('parent_category_id',array('neq'=> 0));
foreach ($collection as $data) {
$collection2 = Mage::getModel('supportportal/supportportal')->getCollection()
-> addFieldToFilter('category_id', array('eq' => $data->getData('parent_category_id')));
foreach ($collection2 as $data2) {
echo '<h4>'.$data2->getData('category_name').'</h4>';//display category having no parent
echo '<ul>';
echo '<li>
<a href="'.$data->getData('category_Url').'">'.$data->getData('category_name').'</a></li>';
//display category having parent
echo '</ul>';
}
}
我們的表結構
fmequestion_category CREATE TABLE fmequestion_category
(
category_id
INT(10)NOT NULL AUTO_INCREMENT,
category_name
VARCHAR(255)字符集UTF8 COLLATE utf8_unicode_ci NOT NULL,
category_description
文本NOT NULL,
category_Url
varchar(255)NOT NULL,
parent_category_id
INT(11)DEFAULT NULL,
store_id
VARCHAR(250)DEFAULT NULL,
meta_title
文本,
meta_keywords
文本,
meta_description
文本,
creation_date
日期時間DEFAULT NULL,
last_updated_date
日期時間DEFAULT NULL,
status
smallint(6)DEFAULT NULL,
PRIMARY KEY(category_id
),
KEY FK_Question_category_parent_category
(parent_category_id
)
)ENGINE = InnoDB的AUTO_INCREMENT = 81默認字符集= UTF8
所以如何我可以顯示象上述 任何人的幫助。謝謝
是什麼structure.Are您使用Magento的類別或自定義類別表? –