下面是一些想法,應該讓你去正確的軌道上:
首先,在安裝腳本,創建實體:
$installer->addAttribute('catalog_product', 'frontend_display', array(
'label' => 'Display Test',
'type' => 'varchar',
'frontend_model' => 'Test_Module/Entity_Attribute_Frontend_CsvExport',
'input' => 'select',
'required' => 0,
'user_defined' => false,
'group' => 'General'
));
確保將frontend_model設置爲模型你將會使用。前端模型影響屬性的顯示(在前端和adminhtml部分)。
接下來,創建自己的類,並重寫的以下功能的一個或兩個:
public function getInputType()
{
return parent::getInputType();
}
public function getInputRendererClass()
{
return "Test_Module_Block_Adminhtml_Entity_Renderer_CsvExport";
}
第一(getInputType()
)用於輸入類型改變爲在輸入型烘烤(見Varien_Data_Form_Element_*
爲選項)。但是,要設置您自己的渲染器類,請使用後一個函數 - getInputRendererClass()
。這就是我要在下面展示:
public function getElementHtml()
{
return Mage::app()->getLayout()->createBlock('Test_Module/Adminhtml_ExportCsv', 'export')->toHtml();
}
這裏,清理東西,我實例化另一個塊,作爲元素本身不具備額外的功能,以顯示按鈕等。
於是最後,創建這個文件:
class Test_Module_Block_Adminhtml_ExportCsv extends Mage_Adminhtml_Block_Widget
{
protected function _prepareLayout()
{
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => $this->__('Generate CSV'),
'onclick' => '',
'class' => 'ajax',
));
$this->setChild('generate', $button);
}
protected function _toHtml()
{
return $this->getChildHtml();
}
}
這不包括AJAX的一部分,但將讓你非常接近得到休息的工作。
你能提供一些更多的解釋嗎?這是完全可以做你所描述的(如果我理解正確的話)。我很樂意花時間,如果我確切地知道我們的目標是什麼,它肯定會有所幫助。 –
我真的很感激它。編輯以添加更多信息 – boruch
您打算將此功能放在哪裏?在產品頁面/屬性管理頁面上? –