Public Member Functions | |
__construct () | |
getItemCount () | |
setItemCount ($itemCount) | |
getProduct () | |
setProduct ($product) | |
getFieldName () | |
getFieldId () | |
isReadonly () | |
getAddButtonId () | |
getDeleteButtonHtml () | |
getTypeSelectHtml () | |
getRequireSelectHtml () | |
getTemplatesHtml () | |
getOptionValues () | |
getCheckboxScopeHtml ($id, $name, $checked=true, $select_id='-1') | |
getPriceValue ($value, $type) | |
Protected Member Functions | |
_prepareLayout () | |
Protected Attributes | |
$_product | |
$_productInstance | |
$_name = 'product[options]' | |
$_id = 'product_option' | |
$_values | |
$_itemCount = 1 |
Definition at line 35 of file Option.php.
__construct | ( | ) |
Constructor
By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes
Reimplemented from Varien_Object.
Definition at line 48 of file Option.php.
00049 { 00050 parent::__construct(); 00051 $this->setTemplate('catalog/product/edit/options/option.phtml'); 00052 }
_prepareLayout | ( | ) | [protected] |
Preparing global layout
You can redefine this method in child classes for changin layout
Reimplemented from Mage_Core_Block_Abstract.
Definition at line 109 of file Option.php.
00110 { 00111 $this->setChild('delete_button', 00112 $this->getLayout()->createBlock('adminhtml/widget_button') 00113 ->setData(array( 00114 'label' => Mage::helper('catalog')->__('Delete Option'), 00115 'class' => 'delete delete-product-option ' 00116 )) 00117 ); 00118 00119 $path = 'global/catalog/product/options/custom/groups'; 00120 00121 foreach (Mage::getConfig()->getNode($path)->children() as $group) { 00122 $this->setChild($group->getName() . '_option_type', 00123 $this->getLayout()->createBlock( 00124 (string) Mage::getConfig()->getNode($path . '/' . $group->getName() . '/render') 00125 ) 00126 ); 00127 } 00128 00129 return parent::_prepareLayout(); 00130 }
getAddButtonId | ( | ) |
Definition at line 132 of file Option.php.
00133 { 00134 $buttonId = $this->getLayout() 00135 ->getBlock('admin.product.options') 00136 ->getChild('add_button')->getId(); 00137 return $buttonId; 00138 }
getCheckboxScopeHtml | ( | $ | id, | |
$ | name, | |||
$ | checked = true , |
|||
$ | select_id = '-1' | |||
) |
Definition at line 259 of file Option.php.
00260 { 00261 $checkedHtml = ''; 00262 if ($checked) { 00263 $checkedHtml = ' checked="checked"'; 00264 } 00265 $selectNameHtml = ''; 00266 $selectIdHtml = ''; 00267 if ($select_id != '-1') { 00268 $selectNameHtml = '[values]['.$select_id.']'; 00269 $selectIdHtml = 'select_'.$select_id.'_'; 00270 } 00271 $checkbox = '<input type="checkbox" id="'.$this->getFieldId().'_'.$id.'_'.$selectIdHtml.$name.'_use_default" class="product-option-scope-checkbox" name="'.$this->getFieldName().'['.$id.']'.$selectNameHtml.'[scope]['.$name.']" value="1" '.$checkedHtml.'/>'; 00272 $checkbox .= '<label class="normal" for="'.$this->getFieldId().'_'.$id.'_'.$selectIdHtml.$name.'_use_default">Use Default Value</label>'; 00273 return $checkbox; 00274 }
getDeleteButtonHtml | ( | ) |
Definition at line 140 of file Option.php.
00141 { 00142 return $this->getChildHtml('delete_button'); 00143 }
getFieldId | ( | ) |
getFieldName | ( | ) |
getItemCount | ( | ) |
getOptionValues | ( | ) |
Definition at line 181 of file Option.php.
00182 { 00183 $optionsArr = array_reverse($this->getProduct()->getOptions(), true); 00184 // $optionsArr = $this->getProduct()->getOptions(); 00185 00186 if (!$this->_values) { 00187 $values = array(); 00188 $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE); 00189 foreach ($optionsArr as $option) { 00190 /* @var $option Mage_Catalog_Model_Product_Option */ 00191 00192 $this->setItemCount($option->getOptionId()); 00193 00194 $value = array(); 00195 00196 $value['id'] = $option->getOptionId(); 00197 $value['item_count'] = $this->getItemCount(); 00198 $value['option_id'] = $option->getOptionId(); 00199 $value['title'] = $this->htmlEscape($option->getTitle()); 00200 $value['type'] = $option->getType(); 00201 $value['is_require'] = $option->getIsRequire(); 00202 $value['sort_order'] = $option->getSortOrder(); 00203 00204 if ($this->getProduct()->getStoreId() != '0') { 00205 $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', is_null($option->getStoreTitle())); 00206 $value['scopeTitleDisabled'] = is_null($option->getStoreTitle())?'disabled':null; 00207 } 00208 00209 if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { 00210 00211 // $valuesArr = array_reverse($option->getValues(), true); 00212 00213 $i = 0; 00214 $itemCount = 0; 00215 foreach ($option->getValues() as $_value) { 00216 /* @var $_value Mage_Catalog_Model_Product_Option_Value */ 00217 $value['optionValues'][$i] = array( 00218 'item_count' => max($itemCount, $_value->getOptionTypeId()), 00219 'option_id' => $_value->getOptionId(), 00220 'option_type_id' => $_value->getOptionTypeId(), 00221 'title' => $this->htmlEscape($_value->getTitle()), 00222 'price' => $this->getPriceValue($_value->getPrice(), $_value->getPriceType()), 00223 'price_type' => $_value->getPriceType(), 00224 'sku' => $this->htmlEscape($_value->getSku()), 00225 'sort_order' => $_value->getSortOrder(), 00226 ); 00227 00228 if ($this->getProduct()->getStoreId() != '0') { 00229 $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($_value->getOptionId(), 'title', is_null($_value->getStoreTitle()), $_value->getOptionTypeId()); 00230 $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle())?'disabled':null; 00231 if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { 00232 $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($_value->getOptionId(), 'price', is_null($_value->getstorePrice()), $_value->getOptionTypeId()); 00233 $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice())?'disabled':null; 00234 } 00235 } 00236 $i++; 00237 } 00238 } else { 00239 $value['price'] = $this->getPriceValue($option->getPrice(), $option->getPriceType()); 00240 $value['price_type'] = $option->getPriceType(); 00241 $value['sku'] = $this->htmlEscape($option->getSku()); 00242 $value['max_characters'] = $option->getMaxCharacters(); 00243 $value['file_extension'] = $option->getFileExtension(); 00244 $value['image_size_x'] = $option->getImageSizeX(); 00245 $value['image_size_y'] = $option->getImageSizeY(); 00246 if ($this->getProduct()->getStoreId() != '0' && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { 00247 $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($option->getStorePrice())); 00248 $value['scopePriceDisabled'] = is_null($option->getStorePrice())?'disabled':null; 00249 } 00250 } 00251 $values[] = new Varien_Object($value); 00252 } 00253 $this->_values = $values; 00254 } 00255 00256 return $this->_values; 00257 }
getPriceValue | ( | $ | value, | |
$ | type | |||
) |
Definition at line 276 of file Option.php.
00277 { 00278 if ($type == 'percent') { 00279 return number_format($value, 2, null, ''); 00280 } elseif ($type == 'fixed') { 00281 return number_format($value, 2, null, ''); 00282 } 00283 }
getProduct | ( | ) |
Get Product
Definition at line 70 of file Option.php.
00071 { 00072 if (!$this->_productInstance) { 00073 if ($product = Mage::registry('product')) { 00074 $this->_productInstance = $product; 00075 } else { 00076 $this->_productInstance = Mage::getSingleton('catalog/product'); 00077 } 00078 } 00079 00080 return $this->_productInstance; 00081 }
getRequireSelectHtml | ( | ) |
Definition at line 158 of file Option.php.
00159 { 00160 $select = $this->getLayout()->createBlock('adminhtml/html_select') 00161 ->setData(array( 00162 'id' => $this->getFieldId().'_{{id}}_is_require', 00163 'class' => 'select' 00164 )) 00165 ->setName($this->getFieldName().'[{{id}}][is_require]') 00166 ->setOptions(Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray()); 00167 00168 return $select->getHtml(); 00169 }
getTemplatesHtml | ( | ) |
Definition at line 171 of file Option.php.
00172 { 00173 $templates = $this->getChildHtml('text_option_type') . "\n" . 00174 $this->getChildHtml('file_option_type') . "\n" . 00175 $this->getChildHtml('select_option_type') . "\n" . 00176 $this->getChildHtml('date_option_type'); 00177 00178 return $templates; 00179 }
getTypeSelectHtml | ( | ) |
Definition at line 145 of file Option.php.
00146 { 00147 $select = $this->getLayout()->createBlock('adminhtml/html_select') 00148 ->setData(array( 00149 'id' => $this->getFieldId().'_{{id}}_type', 00150 'class' => 'select select-product-option-type required-option-select' 00151 )) 00152 ->setName($this->getFieldName().'[{{id}}][type]') 00153 ->setOptions(Mage::getSingleton('adminhtml/system_config_source_product_options_type')->toOptionArray()); 00154 00155 return $select->getHtml(); 00156 }
isReadonly | ( | ) |
Check block is readonly
Definition at line 104 of file Option.php.
00105 { 00106 return $this->getProduct()->getOptionsReadonly(); 00107 }
setItemCount | ( | $ | itemCount | ) |
setProduct | ( | $ | product | ) |
$_id = 'product_option' [protected] |
Definition at line 42 of file Option.php.
$_itemCount = 1 [protected] |
Definition at line 46 of file Option.php.
$_name = 'product[options]' [protected] |
$_product [protected] |
Definition at line 37 of file Option.php.
$_productInstance [protected] |
Definition at line 39 of file Option.php.
$_values [protected] |
Definition at line 44 of file Option.php.