2011-06-01 21 views
0

我beginig Magento的自定義部件開發的所有選項,而我已創建我的第一個窗口小部件此定義選項:Magento的 - 得到一個定製的Widget

<text1> 
    <label>Text 1</label> 
    <visible>1</visible> 
    <required>1</required> 
    <type>text</type> 
</text1> 

<text2> 
    <label>Text 2</label> 
    <visible>1</visible> 
    <required>1</required> 
    <type>text</type> 
</text2> 

有了這個功能,我得到我的第一個文本值

protected function _getText1() { 
    $text1 = $this->getData('text1'); 
    if(trim($text1) != ""){ 
     return $text1; 
    } 
} 

我想知道如何在只有一個函數(例如數組)中獲得所有選項(文本字段值)。

非常感謝:)

回答

2

作爲陣列

public function getTextValuesOfMyWidget(){ 
    $textValuesByKey = array(); 
    foreach($this->getData() as $key => $value){ 
     $textValuesByKey[$key] = $value->getYourValueField(); 
    } 
    return $textValuesByKey; 
} 

$this->getData(); // it already returns you all values as an array