Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier:

Mage_Adminhtml_Block_Widget Varien_Data_Form_Element_Renderer_Interface Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getProduct ()
 render (Varien_Data_Form_Element_Abstract $element)
 setElement (Varien_Data_Form_Element_Abstract $element)
 getElement ()
 getValues ()
 getCustomerGroups ($groupId=null)
 getWebsiteCount ()
 isMultiWebsites ()
 getWebsites ()
 getDefaultCustomerGroup ()
 getAddButtonHtml ()
 getPriceColumnHeader ($default)

Protected Member Functions

 _sortTierPrices ($a, $b)
 _prepareLayout ()

Protected Attributes

 $_element = null
 $_customerGroups = null
 $_websites = null


Detailed Description

Definition at line 34 of file Tier.php.


Constructor & Destructor Documentation

__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 41 of file Tier.php.

00042     {
00043         $this->setTemplate('catalog/product/edit/price/tier.phtml');
00044     }


Member Function Documentation

_prepareLayout (  )  [protected]

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 164 of file Tier.php.

00165     {
00166         $this->setChild('add_button',
00167             $this->getLayout()->createBlock('adminhtml/widget_button')
00168                 ->setData(array(
00169                     'label'     => Mage::helper('catalog')->__('Add Tier'),
00170                     'onclick'   => 'tierPriceControl.addItem()',
00171                     'class' => 'add'
00172                 )));
00173         return parent::_prepareLayout();
00174     }

_sortTierPrices ( a,
b 
) [protected]

Definition at line 80 of file Tier.php.

00081     {
00082         if ($a['website_id']!=$b['website_id']) {
00083             return $a['website_id']<$b['website_id'] ? -1 : 1;
00084         }
00085         if ($a['cust_group']!=$b['cust_group']) {
00086             return $this->getCustomerGroups($a['cust_group'])<$this->getCustomerGroups($b['cust_group']) ? -1 : 1;
00087         }
00088         if ($a['price_qty']!=$b['price_qty']) {
00089             return $a['price_qty']<$b['price_qty'] ? -1 : 1;
00090         }
00091         return 0;
00092     }

getAddButtonHtml (  ) 

Definition at line 176 of file Tier.php.

00177     {
00178         return $this->getChildHtml('add_button');
00179     }

getCustomerGroups ( groupId = null  ) 

Definition at line 94 of file Tier.php.

00095     {
00096         if (!$this->_customerGroups) {
00097             $collection = Mage::getModel('customer/group')->getCollection()
00098                 ->load();
00099             $this->_customerGroups = array(
00100                 Mage_Customer_Model_Group::CUST_GROUP_ALL => Mage::helper('catalog')->__('ALL GROUPS'),
00101             );
00102             foreach ($collection->getIterator() as $item) {
00103                 $this->_customerGroups[$item->getId()] = $item->getCustomerGroupCode();
00104             }
00105         }
00106         return is_null($groupId) ? $this->_customerGroups :
00107             (isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null);
00108     }

getDefaultCustomerGroup (  ) 

Definition at line 159 of file Tier.php.

00160     {
00161         return Mage_Customer_Model_Group::CUST_GROUP_ALL;
00162     }

getElement (  ) 

Definition at line 63 of file Tier.php.

00064     {
00065         return $this->_element;
00066     }

getPriceColumnHeader ( default  ) 

Returns customized price column header that was seted through set...

Parameters:
string $default
Returns:
string

Definition at line 188 of file Tier.php.

00189     {
00190         if ($this->hasData('price_column_header')) {
00191             return $this->getData('price_column_header');
00192         } else {
00193             return $default;
00194         }
00195     }

getProduct (  ) 

Definition at line 46 of file Tier.php.

00047     {
00048         return Mage::registry('product');
00049     }

getValues (  ) 

Definition at line 68 of file Tier.php.

00069     {
00070         $values =array();
00071         $data = $this->getElement()->getValue();
00072 
00073         if (is_array($data)) {
00074             usort($data, array($this, '_sortTierPrices'));
00075             $values = $data;
00076         }
00077         return $values;
00078     }

getWebsiteCount (  ) 

Definition at line 110 of file Tier.php.

00111     {
00112         return count($this->getWebsites());
00113     }

getWebsites (  ) 

Definition at line 120 of file Tier.php.

00121     {
00122         if (!is_null($this->_websites)) {
00123             return $this->_websites;
00124         }
00125         $websites = array();
00126         $websites[0] = array(
00127             'name'      => $this->__('All Websites'),
00128             'currency'  => Mage::app()->getBaseCurrencyCode()
00129         );
00130         if (Mage::app()->isSingleStoreMode() || $this->getElement()->getEntityAttribute()->isScopeGlobal()) {
00131             return $websites;
00132         }
00133         elseif ($storeId = $this->getProduct()->getStoreId()) {
00134             $website = Mage::app()->getStore($storeId)->getWebsite();
00135             $websites[$website->getId()] = array(
00136                 'name'      => $website->getName(),
00137                 'currency'  => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00138             );
00139         }
00140         else {
00141             $websites[0] = array(
00142                 'name'      => $this->__('All Websites'),
00143                 'currency'  => Mage::app()->getBaseCurrencyCode()
00144             );
00145             foreach (Mage::app()->getWebsites() as $website) {
00146                 if (!in_array($website->getId(), $this->getProduct()->getWebsiteIds())) {
00147                     continue;
00148                 }
00149                 $websites[$website->getId()] = array(
00150                     'name'      => $website->getName(),
00151                     'currency'  => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00152                 );
00153             }
00154         }
00155         $this->_websites = $websites;
00156         return $this->_websites;
00157     }

isMultiWebsites (  ) 

Definition at line 115 of file Tier.php.

00116     {
00117         return !Mage::app()->isSingleStoreMode();
00118     }

render ( Varien_Data_Form_Element_Abstract element  ) 

Implements Varien_Data_Form_Element_Renderer_Interface.

Definition at line 51 of file Tier.php.

00052     {
00053         $this->setElement($element);
00054         return $this->toHtml();
00055     }

setElement ( Varien_Data_Form_Element_Abstract element  ) 

Definition at line 57 of file Tier.php.

00058     {
00059         $this->_element = $element;
00060         return $this;
00061     }


Member Data Documentation

$_customerGroups = null [protected]

Definition at line 38 of file Tier.php.

$_element = null [protected]

Definition at line 37 of file Tier.php.

$_websites = null [protected]

Definition at line 39 of file Tier.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:22:45 2009 for Magento by  doxygen 1.5.8