1

I'm using the following extension: http://www.magentocommerce.com/magento-connect/we-re-open.html

I got an error loading it on my site:

Invalid method Mage_Page_Block_Html::_(Array
(
    [0] => CLOSED
)
)

Trace:
#0 /home/tx3shop/domains/tx3shop.be/public_html/app/design/frontend/tx3-package/tx3-theme/template/page/2columns-left.phtml(46): Varien_Object->__call('_', Array)
#1 /home/tx3shop/domains/tx3shop.be/public_html/app/design/frontend/tx3-package/tx3-theme/template/page/2columns-left.phtml(46): Mage_Page_Block_Html->_('CLOSED')
#2 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/home/tx3shop/d...')
#3 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/tx3-pa...')
#4 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#5 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#6 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Model/Layout.php(529): Mage_Core_Block_Abstract->toHtml()
#7 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(391): Mage_Core_Model_Layout->getOutput()
#8 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Cms/Helper/Page.php(132): Mage_Core_Controller_Varien_Action->renderLayout()
#9 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#10 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#11 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Cms_IndexController->indexAction()
#12 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#13 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 /home/tx3shop/domains/tx3shop.be/public_html/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Controller_Varien_Front->dispatch()
#15 /home/tx3shop/domains/tx3shop.be/public_html/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#16 /home/tx3shop/domains/tx3shop.be/public_html/index.php(80): Mage::run('', 'store')
#17 {main}

I contacted the author, but got no response :(

The code I use to load the block:

<?php
$dow=array('mon','tue','wed','thu','fri','sat','sun');
foreach($dow as $day) {
  ${$day.'_open'}  = Mage::getStoreConfig('businesshours/general/'.$day.'_open');
  ${$day.'_close'} = Mage::getStoreConfig('businesshours/general/'.$day.'_close');
}
?>
<div class="fullschedule">
<div id="header">
<?php echo "<strong>".$this->__('Business Hours')."</strong>\n" ?>
</div>
<div id="schedule">
<?php
foreach($dow as $day) {
  switch($day) {
    case 'mon': echo $this->__('Monday');
              break;
    case 'tue': echo $this->__('Tuesday');
              break;
    case 'wed': echo $this->__('Wednesday');
              break;
    case 'thu': echo $this->__('Thursday');
              break;
    case 'fri': echo $this->__('Friday');
              break;
    case 'sat': echo $this->__('Saturday');
              break;
    case 'sun': echo $this->__('Sunday');
  }
  if(${$day.'_open'} != '')
    echo ": ".${$day.'_open'}.$this->__(' to ').${$day.'_close'}."<br>\n";
  else
    echo ": ".$this->_('CLOSED')."<br>\n";
}
?>
</div>
</div>

Could anyone tell me why I got that error?

If I use the code bellow, everything works without any errors:

<?php
date_default_timezone_set(Mage::getStoreConfig('businesshours/general/timezone'));
$result=$this->getIsClosed(date('Y-m-d'));
if($result[0]){
  $today_open = $result[1];
  $today_close = $result[2];
} else {
  $today_open = Mage::getStoreConfig('businesshours/general/'.strtolower(date('D')).'_open');
  $today_close = Mage::getStoreConfig('businesshours/general/'.strtolower(date('D')).'_close');
}
$result=$this->getIsClosed(date('Y-m-d',time()+60*60*24));
if($result[0]){
  $tomorrow_open = $result[1];
  $tomorrow_close = $result[2];
} else {
  $tomorrow_open = Mage::getStoreConfig('businesshours/general/'.strtolower(date('D',time()+60*60*24)).'_open');
  $tomorrow_close = Mage::getStoreConfig('businesshours/general/'.strtolower(date('D',time()+60*60*24)).'_close');
}
?>

<div class="box base-mini">
<div class="head">
    <h4><?php echo $this->__('Business Hours')?></h4>
</div>
<div class="content">
    <?php if($today_open!='') echo $this->__('Today').": ".$today_open.$this->__(' to ').$today_close;
              else echo $this->__('Today: CLOSED') ?><br>
    <?php if($tomorrow_open!='') echo $this->__('Tomorrow').": ".$tomorrow_open.$this->__(' to ').$tomorrow_close;
              else echo $this->__('Tomorrow: CLOSED') ?>
<?php if(Mage::getStoreConfig('businesshours/general/fullscheduleurl') != '') ?>
<br><div align=center><a href="<?php echo Mage::getBaseUrl().Mage::getStoreConfig('businesshours/general/fullscheduleurl'); ?>"><?php echo $this->__('View full schedule') ?></a></div>
<div>
</div>
</div>
</div>
<?php
date_default_timezone_set('UTC');
?>
1

This line:

echo ": ".$this->_('CLOSED')."<br>\n";

Should be:

echo ": ".$this->__('CLOSED')."<br>\n";

There is an underscore missing for translation method.

| improve this answer | |
  • I'm also having trouble with the "Override CLOSE on these dates" to work. Do you know if Magento always keep the date in format M-D-Y? Or why this wont work? – gelleby Nov 14 '13 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.