Magento - Bali web design - Bali web developer - get current category

Magento - Bali web design - Bali web developer - get current category

Berikut adalah code untuk memfilter kategori pada view.phtml.

Misalkan anda punya 3 kategori dengan urutan :
Kategori A -> id = 1
Ketagori B -> id = 2
Kategori C -> id = 3

pada kategori A anda ingin memasukkan ‘link 1’, pada kategori B ‘link 2’ dan kategori C ‘link 3’ :

$categoryId =  Mage::getModel('catalog/layer')->getCurrentCategory()->getId(); //untuk mendapatkan kategori yg aktif pada produk

if ($categoryId=='1'){
echo 'link 1';
} elseif ($categoryId=='2'){
echo 'link 2';
} else {
echo 'link 3';
}

Semoga membantu 😀