00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings extends Mage_Adminhtml_Block_Widget_Form
00036 {
00037
00038
00039
00040
00041 protected function _prepareLayout()
00042 {
00043 $onclick = "setSuperSettings('".$this->getContinueUrl()."','attribute-checkbox', 'attributes')";
00044 $this->setChild('continue_button',
00045 $this->getLayout()->createBlock('adminhtml/widget_button')
00046 ->setData(array(
00047 'label' => Mage::helper('catalog')->__('Continue'),
00048 'onclick' => $onclick,
00049 'class' => 'save'
00050 ))
00051 );
00052
00053 $backButton = $this->getLayout()->createBlock('adminhtml/widget_button')
00054 ->setData(array(
00055 'label' => Mage::helper('catalog')->__('Back'),
00056 'onclick' => "setLocation('".$this->getBackUrl()."')",
00057 'class' => 'back'
00058 ));
00059
00060 $this->setChild('back_button', $backButton);
00061 parent::_prepareLayout();
00062 }
00063
00064
00065
00066
00067
00068
00069 protected function _getProduct()
00070 {
00071 return Mage::registry('current_product');
00072 }
00073
00074
00075
00076
00077
00078
00079 protected function _prepareForm()
00080 {
00081 $form = new Varien_Data_Form();
00082 $fieldset = $form->addFieldset('settings', array(
00083 'legend'=>Mage::helper('catalog')->__('Select Configurable Attributes ')
00084 ));
00085
00086 $product = $this->_getProduct();
00087 $attributes = $product->getTypeInstance(true)
00088 ->getSetAttributes($product);
00089
00090 $fieldset->addField('req_text', 'note', array(
00091 'text' => '<ul class="messages"><li class="notice-msg"><ul><li>'
00092 . $this->__('Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available.')
00093 . '</li></ul></li></ul>'
00094 ));
00095
00096 $hasAttributes = false;
00097
00098 foreach ($attributes as $attribute) {
00099 if ($product->getTypeInstance(true)->canUseAttribute($attribute, $product)) {
00100 $hasAttributes = true;
00101 $fieldset->addField('attribute_'.$attribute->getAttributeId(), 'checkbox', array(
00102 'label' => $attribute->getFrontend()->getLabel(),
00103 'title' => $attribute->getFrontend()->getLabel(),
00104 'name' => 'attribute',
00105 'class' => 'attribute-checkbox',
00106 'value' => $attribute->getAttributeId()
00107 ));
00108 }
00109 }
00110
00111 if ($hasAttributes) {
00112 $fieldset->addField('attributes', 'hidden', array(
00113 'name' => 'attribute_validate',
00114 'value' => '',
00115 'class' => 'validate-super-product-attributes'
00116 ));
00117
00118 $fieldset->addField('continue_button', 'note', array(
00119 'text' => $this->getChildHtml('continue_button'),
00120 ));
00121 }
00122 else {
00123 $fieldset->addField('note_text', 'note', array(
00124 'text' => $this->__('This attribute set don\'t have attributes which we can use for configurable product')
00125 ));
00126 $fieldset->addField('back_button', 'note', array(
00127 'text' => $this->getChildHtml('back_button'),
00128 ));
00129 }
00130
00131
00132 $this->setForm($form);
00133
00134 return parent::_prepareForm();
00135 }
00136
00137
00138
00139
00140
00141
00142 public function getContinueUrl()
00143 {
00144 return $this->getUrl('*/*/new', array(
00145 '_current' => true,
00146 'attributes' => '{{attributes}}'
00147 ));
00148 }
00149
00150
00151
00152
00153
00154
00155 public function getBackUrl()
00156 {
00157 return $this->getUrl('*/*/new', array('set'=>null, 'type'=>null));
00158 }
00159 }