Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Directory_Block_Adminhtml_Frontend_Currency_Base
  • Mage_Directory_Block_Adminhtml_Frontend_Region_Updater
  • Mage_Directory_Block_Currency
  • Mage_Directory_Block_Data
  • Mage_Directory_CurrencyController
  • Mage_Directory_Helper_Data
  • Mage_Directory_Helper_Url
  • Mage_Directory_Model_Country
  • Mage_Directory_Model_Country_Api
  • Mage_Directory_Model_Country_Api_V2
  • Mage_Directory_Model_Country_Format
  • Mage_Directory_Model_Currency
  • Mage_Directory_Model_Currency_Filter
  • Mage_Directory_Model_Currency_Import_Abstract
  • Mage_Directory_Model_Currency_Import_Webservicex
  • Mage_Directory_Model_Mysql4_Country
  • Mage_Directory_Model_Mysql4_Country_Collection
  • Mage_Directory_Model_Mysql4_Country_Format
  • Mage_Directory_Model_Mysql4_Country_Format_Collection
  • Mage_Directory_Model_Mysql4_Currency
  • Mage_Directory_Model_Mysql4_Currency_Collection
  • Mage_Directory_Model_Mysql4_Region
  • Mage_Directory_Model_Mysql4_Region_Collection
  • Mage_Directory_Model_Observer
  • Mage_Directory_Model_Region
  • Mage_Directory_Model_Region_Api
  • Mage_Directory_Model_Region_Api_V2
  • Mage_Directory_Model_Resource_Country
  • Mage_Directory_Model_Resource_Country_Collection
  • Mage_Directory_Model_Resource_Country_Format
  • Mage_Directory_Model_Resource_Country_Format_Collection
  • Mage_Directory_Model_Resource_Currency
  • Mage_Directory_Model_Resource_Region
  • Mage_Directory_Model_Resource_Region_Collection

Exceptions

  • Mage_Directory_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Directory
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Country collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Directory
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Directory_Model_Resource_Region_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 36: {
 37:     /**
 38:      * Locale region name table name
 39:      *
 40:      * @var string
 41:      */
 42:     protected $_regionNameTable;
 43: 
 44:     /**
 45:      * Country table name
 46:      *
 47:      * @var string
 48:      */
 49:     protected $_countryTable;
 50: 
 51:     /**
 52:      * Define main, country, locale region name tables
 53:      *
 54:      */
 55:     protected function _construct()
 56:     {
 57:         $this->_init('directory/region');
 58: 
 59:         $this->_countryTable    = $this->getTable('directory/country');
 60:         $this->_regionNameTable = $this->getTable('directory/country_region_name');
 61: 
 62:         $this->addOrder('name', Varien_Data_Collection::SORT_ORDER_ASC);
 63:         $this->addOrder('default_name', Varien_Data_Collection::SORT_ORDER_ASC);
 64:     }
 65: 
 66:     /**
 67:      * Initialize select object
 68:      *
 69:      * @return Mage_Directory_Model_Resource_Region_Collection
 70:      */
 71:     protected function _initSelect()
 72:     {
 73:         parent::_initSelect();
 74:         $locale = Mage::app()->getLocale()->getLocaleCode();
 75: 
 76:         $this->addBindParam(':region_locale', $locale);
 77:         $this->getSelect()->joinLeft(
 78:             array('rname' => $this->_regionNameTable),
 79:             'main_table.region_id = rname.region_id AND rname.locale = :region_locale',
 80:             array('name'));
 81: 
 82:         return $this;
 83:     }
 84: 
 85:     /**
 86:      * Filter by country_id
 87:      *
 88:      * @param string|array $countryId
 89:      * @return Mage_Directory_Model_Resource_Region_Collection
 90:      */
 91:     public function addCountryFilter($countryId)
 92:     {
 93:         if (!empty($countryId)) {
 94:             if (is_array($countryId)) {
 95:                 $this->addFieldToFilter('main_table.country_id', array('in' => $countryId));
 96:             } else {
 97:                 $this->addFieldToFilter('main_table.country_id', $countryId);
 98:             }
 99:         }
100:         return $this;
101:     }
102: 
103:     /**
104:      * Filter by country code (ISO 3)
105:      *
106:      * @param string $countryCode
107:      * @return Mage_Directory_Model_Resource_Region_Collection
108:      */
109:     public function addCountryCodeFilter($countryCode)
110:     {
111:         $this->getSelect()
112:             ->joinLeft(
113:                 array('country' => $this->_countryTable),
114:                 'main_table.country_id = country.country_id'
115:                 )
116:             ->where('country.iso3_code = ?', $countryCode);
117: 
118:         return $this;
119:     }
120: 
121:     /**
122:      * Filter by Region code
123:      *
124:      * @param string|array $regionCode
125:      * @return Mage_Directory_Model_Resource_Region_Collection
126:      */
127:     public function addRegionCodeFilter($regionCode)
128:     {
129:         if (!empty($regionCode)) {
130:             if (is_array($regionCode)) {
131:                 $this->addFieldToFilter('main_table.code', array('in' => $regionCode));
132:             } else {
133:                 $this->addFieldToFilter('main_table.code', $regionCode);
134:             }
135:         }
136:         return $this;
137:     }
138: 
139:     /**
140:      * Filter by region name
141:      *
142:      * @param string|array $regionName
143:      * @return Mage_Directory_Model_Resource_Region_Collection
144:      */
145:     public function addRegionNameFilter($regionName)
146:     {
147:         if (!empty($regionName)) {
148:             if (is_array($regionName)) {
149:                 $this->addFieldToFilter('main_table.default_name', array('in' => $regionName));
150:             } else {
151:                 $this->addFieldToFilter('main_table.default_name', $regionName);
152:             }
153:         }
154:         return $this;
155:     }
156: 
157:     /**
158:      * Convert collection items to select options array
159:      *
160:      * @return array
161:      */
162:     public function toOptionArray()
163:     {
164:         $options = $this->_toOptionArray('region_id', 'default_name', array('title' => 'default_name'));
165:         if (count($options) > 0) {
166:             array_unshift($options, array(
167:                 'title '=> null,
168:                 'value' => '0',
169:                 'label' => Mage::helper('directory')->__('-- Please select --')
170:             ));
171:         }
172:         return $options;
173:     }
174: }
175: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0