1

I have multiple stores and I would like to have different text and images, while the stores are in maintenance mode. To do that I need to change the 503.phtml file .

This is the default content of the file:

<div id="main" class="col-main">
<!-- [start] content -->
    <div class="page-title">
        <h1>Service Temporarily Unavailable</h1>
    </div>
    <p>The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.</p>
<!-- [end] content -->
</div>

Obviously I cannot use the Mage::app()->getStore(), because the Mage.php is not included, but before I start to hardcode it, by getting the domain name using php , I want to ask you if there is another way to do this ?

Thank you!

  • have you tried my way? Have you found any other way? If yes, please share the updates. – Mohit Kumar Arora May 3 '18 at 13:49
  • 1
    @MohitKumarArora Thank you for posting an answer, but I realized that query ing the db during maintenance mode, in my case , is not a good idea, that's why I stick with my answer (hardcoded way , but it works ). Thank you :) – Attila Naghi May 7 '18 at 6:27
0

How are you setting the store code etc? If you look further in index.php you will see

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

If you're extra lazy just copy these checks into the 503.phtml and switch on them.

  • ok, and then what ? :) what is your approach ? – Attila Naghi Apr 30 '18 at 14:14
  • Sorry, I thought your question was about how to detect the store/web code when in maintenance mode – Richard Apr 30 '18 at 14:16
0

Since, extracting information from the database is not a good idea, during maintenance mode (especially when you are working with imports :) ), the only way I did it, is using the base url, by getting it via PHP .

<?php
  $url = rtrim($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'],'/');
?>
<?php if ($url === 'myurl.nl'): ?>
//html code here
<?php elseif($url === 'myurl.de'): ?>
//html code here
<?php else: //default ?>
//html code here
<?php endif; ?>
0

Although I have not tried the solution yet, I hope it should work.

  • Create static blocks (having the same identifier name) for each store and add content as per your requirement.
  • Call the static block in the 503.phtml file.

Since the identifier is same, Magento will automatically call appropriate static block per store.

Update: You can use code like below to allow Magento functions in 503.phtml file:

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$_layout  = Mage::getSingleton('core/layout');
$_block   = $_layout->createBlock('cms/block')->setBlockId('[block-identifier]');

echo $_block->toHtml();

Please let me know if it makes sense.

  • loading the static block , like: echo $this->getLayout()->createBlock('cms/block')->setBlockId('maintenance_mode')->toHtml(); , is not working . Is there another way ? – Attila Naghi Apr 30 '18 at 14:04
  • How would this work when Mage::app() is never being started? – Richard Apr 30 '18 at 14:14
  • @Richard As I said the Mage.php file is not included here , so nope :) – Attila Naghi Apr 30 '18 at 14:19
  • @Chester, I have updated my answer. – Mohit Kumar Arora Apr 30 '18 at 18:11

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.