*/ class Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid extends Mage_Adminhtml_Block_Widget_Grid { /** * Website filter * * @var int */ protected $_websiteId; /** * Condition filter * * @var string */ protected $_conditionName; /** * Define grid properties * * @return void */ public function __construct() { parent::__construct(); $this->setId('shippingTablerateGrid'); $this->_exportPageSize = 10000; } /** * Set current website * * @param int $websiteId * @return Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */ public function setWebsiteId($websiteId) { $this->_websiteId = Mage::app()->getWebsite($websiteId)->getId(); return $this; } /** * Retrieve current website id * * @return int */ public function getWebsiteId() { if (is_null($this->_websiteId)) { $this->_websiteId = Mage::app()->getWebsite()->getId(); } return $this->_websiteId; } /** * Set current website * * @param int $websiteId * @return Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */ public function setConditionName($name) { $this->_conditionName = $name; return $this; } /** * Retrieve current website id * * @return int */ public function getConditionName() { return $this->_conditionName; } /** * Prepare shipping table rate collection * * @return Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */ protected function _prepareCollection() { /** @var $collection Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection */ $collection = Mage::getResourceModel('shipping/carrier_tablerate_collection'); $collection->setConditionFilter($this->getConditionName()) ->setWebsiteFilter($this->getWebsiteId()); $this->setCollection($collection); return parent::_prepareCollection(); } /** * Prepare table columns * * @return Mage_Adminhtml_Block_Widget_Grid */ protected function _prepareColumns() { $this->addColumn('dest_country', array( 'header' => Mage::helper('adminhtml')->__('Country'), 'index' => 'dest_country', 'default' => '*', )); $this->addColumn('dest_region', array( 'header' => Mage::helper('adminhtml')->__('Region/State'), 'index' => 'dest_region', 'default' => '*', )); $this->addColumn('dest_zip', array( 'header' => Mage::helper('adminhtml')->__('Zip/Postal Code'), 'index' => 'dest_zip', 'default' => '*', )); $label = Mage::getSingleton('shipping/carrier_tablerate') ->getCode('condition_name_short', $this->getConditionName()); $this->addColumn('condition_value', array( 'header' => $label, 'index' => 'condition_value', )); $this->addColumn('price', array( 'header' => Mage::helper('adminhtml')->__('Shipping Price'), 'index' => 'price', )); return parent::_prepareColumns(); } }