1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings extends Mage_Adminhtml_Block_Widget_Form
36: {
37: 38: 39: 40:
41: protected function _prepareLayout()
42: {
43: $onclick = "setSuperSettings('".$this->getContinueUrl()."','attribute-checkbox', 'attributes')";
44: $this->setChild('continue_button',
45: $this->getLayout()->createBlock('adminhtml/widget_button')
46: ->setData(array(
47: 'label' => Mage::helper('catalog')->__('Continue'),
48: 'onclick' => $onclick,
49: 'class' => 'save'
50: ))
51: );
52:
53: $backButton = $this->getLayout()->createBlock('adminhtml/widget_button')
54: ->setData(array(
55: 'label' => Mage::helper('catalog')->__('Back'),
56: 'onclick' => "setLocation('".$this->getBackUrl()."')",
57: 'class' => 'back'
58: ));
59:
60: $this->setChild('back_button', $backButton);
61: parent::_prepareLayout();
62: }
63:
64: 65: 66: 67: 68:
69: protected function _getProduct()
70: {
71: return Mage::registry('current_product');
72: }
73:
74: 75: 76: 77: 78:
79: protected function _prepareForm()
80: {
81: $form = new Varien_Data_Form();
82: $fieldset = $form->addFieldset('settings', array(
83: 'legend'=>Mage::helper('catalog')->__('Select Configurable Attributes ')
84: ));
85:
86: $product = $this->_getProduct();
87: $attributes = $product->getTypeInstance(true)
88: ->getSetAttributes($product);
89:
90: $fieldset->addField('req_text', 'note', array(
91: 'text' => '<ul class="messages"><li class="notice-msg"><ul><li>'
92: . $this->__('Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available.')
93: . '</li></ul></li></ul>'
94: ));
95:
96: $hasAttributes = false;
97:
98: foreach ($attributes as $attribute) {
99: if ($product->getTypeInstance(true)->canUseAttribute($attribute, $product)) {
100: $hasAttributes = true;
101: $fieldset->addField('attribute_'.$attribute->getAttributeId(), 'checkbox', array(
102: 'label' => $attribute->getFrontend()->getLabel(),
103: 'title' => $attribute->getFrontend()->getLabel(),
104: 'name' => 'attribute',
105: 'class' => 'attribute-checkbox',
106: 'value' => $attribute->getAttributeId()
107: ));
108: }
109: }
110:
111: if ($hasAttributes) {
112: $fieldset->addField('attributes', 'hidden', array(
113: 'name' => 'attribute_validate',
114: 'value' => '',
115: 'class' => 'validate-super-product-attributes'
116: ));
117:
118: $fieldset->addField('continue_button', 'note', array(
119: 'text' => $this->getChildHtml('continue_button'),
120: ));
121: }
122: else {
123: $fieldset->addField('note_text', 'note', array(
124: 'text' => $this->__('This attribute set does not have attributes which we can use for configurable product')
125: ));
126: $fieldset->addField('back_button', 'note', array(
127: 'text' => $this->getChildHtml('back_button'),
128: ));
129: }
130:
131:
132: $this->setForm($form);
133:
134: return parent::_prepareForm();
135: }
136:
137: 138: 139: 140: 141:
142: public function getContinueUrl()
143: {
144: return $this->getUrl('*/*/new', array(
145: '_current' => true,
146: 'attributes' => '{{attributes}}'
147: ));
148: }
149:
150: 151: 152: 153: 154:
155: public function getBackUrl()
156: {
157: return $this->getUrl('*/*/new', array('set'=>null, 'type'=>null));
158: }
159: }
160: