1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Bundle
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Bundle Price View Attribute Renderer
30: *
31: * @category Mage
32: * @package Mage_Bundle
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Bundle_Model_Product_Attribute_Source_Price_View extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
36: {
37: /**
38: * Get all options
39: *
40: * @return array
41: */
42: public function getAllOptions()
43: {
44: if (is_null($this->_options)) {
45: $this->_options = array(
46: array(
47: 'label' => Mage::helper('bundle')->__('As Low as'),
48: 'value' => 1
49: ),
50: array(
51: 'label' => Mage::helper('bundle')->__('Price Range'),
52: 'value' => 0
53: ),
54: );
55: }
56: return $this->_options;
57: }
58:
59: /**
60: * Get a text for option value
61: *
62: * @param string|integer $value
63: * @return string
64: */
65: public function getOptionText($value)
66: {
67: $options = $this->getAllOptions();
68: foreach ($options as $option) {
69: if ($option['value'] == $value) {
70: return $option['label'];
71: }
72: }
73: return false;
74: }
75:
76: /**
77: * Retrieve flat column definition
78: *
79: * @return array
80: */
81: public function getFlatColums()
82: {
83: $attributeCode = $this->getAttribute()->getAttributeCode();
84: $column = array(
85: 'unsigned' => false,
86: 'default' => null,
87: 'extra' => null
88: );
89:
90: if (Mage::helper('core')->useDbCompatibleMode()) {
91: $column['type'] = 'int';
92: $column['is_null'] = true;
93: } else {
94: $column['type'] = Varien_Db_Ddl_Table::TYPE_INTEGER;
95: $column['nullable'] = true;
96: $column['comment'] = 'Bundle Price View ' . $attributeCode . ' column';
97: }
98:
99: return array($attributeCode => $column);
100: }
101:
102: /**
103: * Retrieve Select for update Attribute value in flat table
104: *
105: * @param int $store
106: * @return Varien_Db_Select|null
107: */
108: public function getFlatUpdateSelect($store)
109: {
110: return Mage::getResourceModel('eav/entity_attribute_option')
111: ->getFlatUpdateSelect($this->getAttribute(), $store, false);
112: }
113: }
114: