2015-10-16 94 views

回答

0

就像Magento中你有多個選項的一切。選擇在您的項目中更有意義。

  1. 更改管理中第二級別類別的te模板或在該類別中添加自定義xml。

  2. 附加一個事件檢查當前的類別級別,並添加一個新的句柄,當類別是第二個。 之後,您可以使用layout xml來更改模板。 要添加新的手柄,你應該使用:

`

$_category = Mage::registry('current_category'); 
if ($_category instanceof Mage_Catalog_Model_Category && $_category->getLevel() == 2){ 
    $update = $observer->getEvent()->getLayout()->getUpdate(); 
    $update->addHandle('CATEGORY_LEVEL_2'); 
} 

編號:http://magebase.com/magento-tutorials/creating-custom-layout-handles/

  • 就像你還可以將一個觀察者第二個選項直接阻止和更改模板。對於此事件是和觀察者代碼如下:
  • `

    if ($observer->getBlock() instanceof Mage_Catalog_Block_Category_View) { 
        $observer->getBlock()->setTemplate('my_module/newtemplate.phtml'); 
    } 
    

    編號:https://magento.stackexchange.com/questions/22218/remove-price-block-via-event-observer