Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion app/code/community/IntegerNet/Autoshipping/Block/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,30 @@ public function getSelectedCountryId()
{
return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCountryId();
}
}

public function getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country')
{
if (is_null($defValue)) {
$defValue = $this->getCountryId();
}
$cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode();
if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) {
$options = unserialize($cache);
} else {
$options = $this->getCountryCollection()->toOptionArray();
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache(serialize($options), $cacheKey, array('config'));
}
}
$html = $this->getLayout()->createBlock('core/html_select')
->setName($name)
->setId($id)
->setTitle(Mage::helper('directory')->__($title))
->setClass('validate-select')
->setValue($defValue)
->setOptions($options)
->getHtml();

return $html;
}
}
26 changes: 1 addition & 25 deletions app/code/community/IntegerNet/Autoshipping/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,6 @@

class IntegerNet_Autoshipping_Helper_Data extends Mage_Core_Helper_Abstract
{
public function getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country')
{
if (is_null($defValue)) {
$defValue = $this->getCountryId();
}
$cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode();
if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) {
$options = unserialize($cache);
} else {
$options = $this->getCountryCollection()->toOptionArray();
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache(serialize($options), $cacheKey, array('config'));
}
}
$html = $this->getLayout()->createBlock('core/html_select')
->setName($name)
->setId($id)
->setTitle(Mage::helper('directory')->__($title))
->setClass('validate-select')
->setValue($defValue)
->setOptions($options)
->getHtml();

return $html;
}

}