我有一個CMS頁面,我要對顯示產品的下列更新XML代碼:如何獲取當前catageory id?
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/wholesale-list.phtml">
<action method="setCategoryId"><category_id>191</category_id></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
我試圖讓我在佈局中設置的ID,但沒有這樣的運氣。我曾嘗試:
$_category = Mage::registry(‘current_category’);
$currentCategoryId= $_category->getId();
和
$layer = Mage::getSingleton(‘catalog/layer’);
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();
但是這些方法都沒有工作。有誰知道我如何獲得ID?
太謝謝你了! – Chris 2011-04-01 14:20:58