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

<!DOCTYPE html>
    <meta name="robots" content="noindex,nofollow"/>
<a href="http://<?php echo $_SERVER['HTTP_HOST'] ?>/?___store=test_store">Go to test store</a>

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.

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.

  • An immediate improvement would be to not trust user input ($_COOKIE['testing']) as a path parameter when dealing with include paths. – benmarks Dec 3 '13 at 19:28

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.

  • For GIT (CVS is way too old now days) I agree and that is the correct way to do. But in the case you want the final test on the production installation, so after your local dev has been completed and is ready to test. Of course database manipulation shouldn't be done that can break anything, here it's only file manipulation. – Shadowbob Dec 2 '13 at 21:41
  • I'm talking about VCS (version control system, whatever you use, BUT USE ONE! :-)) not CVS sorry. – Fabian Blechschmidt Dec 2 '13 at 22:15

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.