Question

This post is not a question but an experience share.

Sometimes we need to test our Store in live environment with the live database, or be able to show clients how the new version will look like without installing another test server, or in the case you don't want to create another GIT branch on your local server and don't want to push to Live critical files...

My solution is to create another codepool just for testing purpose.

First create a file called testing.php on Magento's Root (next to index.php) with this code

<?php
setcookie('testing',true);
?>
<!DOCTYPE html>
<html>
<head>
    <title>test</title>
    <meta name="robots" content="noindex,nofollow"/>
</head>
<body>
<a href="http://<?php echo $_SERVER['HTTP_HOST'] ?>/?___store=test_store">Go to test store</a>
</body>
</html>

Then we modify Mage.php (it's a slight modification so can be deleted without incidences with a Magento update) to make the Autoload part to look like this

if (isset($_COOKIE['testing'])) $paths[] = BP . DS . 'app' . DS . 'code' . DS . 'test';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

Now if you want to modify your code you simply copy the folder from app/code/local to app/code/test your code should work fine at this point.

Frontend
For the frontend it's easier as you just need to create the store view with the code test_store in Configuration change your current store to the test go to Design > head > Default Robots > NOINDEX, NOFOLLOW
Then Design > Themes should have the default to your main theme and all others to your test theme.
If you have a multilingual store that has a selection you will have to create a website instead of store view.

There is certainly a better solutions, please share if you have it.

Was it helpful?

Solution

How to

Setting up a test environment:

  1. Checkout VCS
  2. Copy database
  3. Copy and modify local.xml

That's it.

Maybe you want to copy the media folder.

The point is, you want all your files in VCS, you want branches for every instance (test, stage, live, ci, ...) so you have full control over what you deploy and know what your CI or customer is testing.

How not to

And you definitly don't want to deploy ANY files to live to test something, because if you didn't test well (and devs tend to test only things they implement), you might crash checkout, catalog, cms pages, whatever is important for your customer and has nothing to do with the feature you just implemented.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top