2014-06-09 28 views
0

嗨我正在開發一個magento擴展,其中我需要在magento順序詳細信息中顯示產品自定義屬性。我想通過xml添加它,而無需編輯/覆蓋任何核心文件。在magento管理命令詳細信息中插入通過xml的自定義項目變量Magento

現在,我編輯以下文件以顯示僅用於測試的自定義屬性值。

應用程序/設計/ adminhtml /默認/缺省的/模板/銷售/項目/列/ name.phtml

,但我知道這是不正確的方法。所以請建議我如何通過xml按塊插入它。

下面是屏幕截圖鏈接

http://awesomescreenshot.com/0e42y3ac8d

回答

1

問題解決了,但與Java腳本函數的幫助。

要添加順序查看頁面上的領域,我們需要做的:

  1. 添加布局在您的配置文件:
<adminhtml> 
    <layout> 
     <updates> 
      <customattribute> 
       <file>customattribute.xml</file> 
      </customattribute> 
     </updates> 
    </layout> 
</adminhtml> 
  1. 添加設計佈局adminhtml 「app/design/adminhtml/default/default/layout/customattribute.xml」
<layout version="0.1.0"> 
    <adminhtml_sales_order_view> 
     <reference name="order_items"> 
      <block type="customattribute/prototal" name="order_item_extra_info" template="customattribute/productdesign.phtml"/> 
     </reference> 
    </adminhtml_sales_order_view> 
</layout> 
  1. 添加模板文件 「應用程序/設計/ adminhtml /默認/缺省的/模板/ customattribute/productdesign.phtml」。請做一些示例代碼的文件格式。
<?php 
$_item = $this->getItem(); 
$sku = $_item->getSku(); 
echo '<div style="display:none;" id="id_order_item_'.$_item->getID().'"> <strong>'.$this->helper('sales')->__('Artwork ID').':</strong>'.$_item->getArtworkID().'</div>'; ?> 
<script> 
function codeAddress<?php echo $_item->getID(); ?>() { 
      var html = document.getElementById('id_order_item_<?php echo $_item->getID(); ?>').innerHTML; 
      var elem = document.getElementById('order_item_<?php echo $_item->getID(); ?>').children[0].innerHTML; 
      document.getElementById('order_item_<?php echo $_item->getID(); ?>').children[0].innerHTML = elem+html; 
     } 
codeAddress<?php echo $_item->getID(); ?>(); 
</script> 
  1. 對於您的模板文件中獲取項目,你需要定義一個塊 「CustomAttribute /座/ Adminhtml/Prototal.php」

類NameSpace_ModuleName_Block_Prototal擴展 Mage_Core_Block_Template public function setItem(Varien_Ob ject $ item){ $ this-> setData('item',$ item); return $ this; }

public function getItem() { 
     return $this->_getData('item'); 
    } 

} 

請評論有人發現任何問題或問題。

0

你應該只覆蓋塊

<config> 
    <global> 
     <blocks> 
      <tag> 
       <rewrite> 
        <product_list>Module_Tag_Block_Product_List</product_list> 
       </rewrite> 
      </tag> 
     </blocks> 
    </global> 
</config> 
相關問題