2

I created a custom maintenance page which appears after setting the maintenance.flag file.

The custom page has a few forms which I copied from the normal page, but they are not working. Validation and date time picking works but If I send the form then I get 503 service unavailable in the network analysis.

503

I need the forms so that users can contact me and order stuff while the page is down.

It works without problems on the main page if the maintenance.flag is not set?

How can I allow the form on maintenance mode?


I tried to allow Mage by putting the following code at the top in errors/default/page.phtml:

error_reporting(E_ALL | E_STRICT);
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();

But I still can't access any controller and get 503 Service Unavailable in the developer console after attempting to submit the form.


Please describe the steps needed to allow specific controllers in maintenance mode. I try to let users subscribe to my newsletter and send the contact form, but they should not be allowed to shop.


EDIT: This question is obviously not a duplicate of (1.9.0.1 Maintenance Mode) because I don't ask how to put magento in maintenance mode. Learn english please @MagenX.

5
  • 1
    Possible duplicate of 1.9.0.1 Maintenance Mode
    – MagenX
    Commented Jun 9, 2018 at 8:39
  • 2
    @MagenX Please understand the question what he wants. Commented Jun 9, 2018 at 8:47
  • he wants to find errors folder, open 503.php processor.php 503.phtml and see how it works...
    – MagenX
    Commented Jun 9, 2018 at 18:47
  • @MagenX, how is it a duplicate, I don't ask how to put magento in maintenance mode.
    – Black
    Commented Jun 11, 2018 at 7:08
  • hmm, I just look at the accepted answer and the duplicate question, trying to understand who needs to learn English here ... do you need to read the same thing twice? lol
    – MagenX
    Commented Oct 30, 2019 at 11:58

2 Answers 2

3
+50

As your website is in maintenance mode then other codes will not work. If you check the index.php file in your magento root folder then you can find that magento will not run further when they find maintenance file in your root directory.

You can solve this by creating a custom php file in your magento root and include the Mage.php after that you can use the magento functions according to your requirement.

METHOD 2

You will get route name for the pages you want to consider by following code:

$routename = Mage::app()->getRequest()->getRouteName();

After that you need to put the condition like below:

if (file_exists($maintenanceFile) && $routename != 'YOUR_ROUTE_NAME') {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

You can get your routename(YOUR_ROUTE_NAME) by echo $routename just above the below code:

if (file_exists($maintenanceFile) && $routename != 'YOUR_ROUTE_NAME')

METHOD 3:

If Method 2 was not working, then try:

$routename = parse_url($_SERVER['REQUEST_URI']);

if (file_exists($maintenanceFile) && $routename['path'] !== "/newsletter/subscriber/new/") { ... }

You can get your routename(YOUR_ROUTE_NAME) by echo $routename['path'] just above the below code:

if (file_exists($maintenanceFile) && $routename['path'] != 'YOUR_ROUTE_NAME')
13
  • By "custom php file" do you mean a custom index.php? Or what file exactly do you mean sir?
    – Black
    Commented Jun 9, 2018 at 7:36
  • 1
    Create abc.php on you magento root and include Mage.php with proper path. Now you can use this file as controller action and use contact us post action code here in your abc.php file. Commented Jun 9, 2018 at 7:52
  • And how does it work if I need it in /errors/default/page.phtml instead?
    – Black
    Commented Jun 11, 2018 at 8:55
  • Put your conditions here in index.php(if (file_exists($maintenanceFile)) ). You can put your controller actions here so that this will not allow to enter on that condition and page works perfectly for you. Commented Jun 11, 2018 at 11:37
  • How exactly can I put a controller action there, I don't know what you are talking about to be honest. An example would be great.
    – Black
    Commented Jun 11, 2018 at 11:39
0

By default, You can not allow this. If you check Magento index.php file, you will found the below code:

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

You can add your Custom condition here with Custom URL check.

Hope this help!!

2
  • "You can add your Custom condition here with Custom URL check." Any example?
    – Black
    Commented Jun 11, 2018 at 7:09
  • As we are applying condition before Magento library load. So you need to use $_SERVER['REQUEST_URI'] to check the URl and apply condition accordingly. Commented Jun 11, 2018 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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