开发者

Magento - get all options of a custom Widget

I'm beginig the development of Magento custom widgets, and I have create for my first Widget this custom options:

<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>

With this function I get My first text value

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

I want to know how ca开发者_如何学Gon I get all my options (text fields values) in only one function (with an array for example).

Thanks a lot :)


as array

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

or

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜