2014-03-06 92 views

回答

0

IVA,您可以使用Magento的事件功能的話..... 我創建一個擴展的話....

應用程序/代碼/本地/艾米特/ Autoupdatecat的/ etc/config.xml中

<?xml version="1.0" ?> 
<config> 
    <modules> 
     <Amit_Autoupdatecat> 
      <version>1.0.0</version> 
     </Amit_Autoupdatecat> 
    </modules> 


    <global> 
      <models> 
       <autoupdatecat> 
        <class>Amit_Autoupdatecat_Model</class> 
       </autoupdatecat> 
      </models> 
     </global> 
      <global> 
      <events> 
       <catalog_category_save_commit_after> 
     <observers> 
      <autoupdatecatgories> 
       <type>singleton</type> 
       <class>autoupdatecat/observer</class> 
       <method>saveCategorytabs</method> 
      </autoupdatecatgories> 
     </observers> 
    </catalog_category_save_commit_after> 
      </events> 
     </global>  

    </config> 

應用程序/代碼/本地/艾米特/ Autoupdatecat /型號/ Observer.php

<?php 

class Amit_Autoupdatecat_Model_Observer 
{ 
public function saveCategorytabs($observer) 
      { 

       /*get category value */ 
      $data= $observer->getEvent()->getData(); 
        $name=$data['name']; 
     /*more fields and write code in below for custom table*/ 


      } 

} 
+0

請寫出更多細節 –

+0

謝謝對這個阿米特來說。 我Observer.php具有此方法: 公共函數saveCategory($觀察者) \t { \t \t $事件= $ observer-> getEvent(); \t \t $ category = $ event-> getCategory();如果($ category-> getCustomAttribute()=== 1){ \t Mage :: log('yes');其他{ \t}其他{ \t Mage :: log('no'); \t} } 而不是getData()我需要getEvent()來獲取getCategory() – iva

相關問題