Staging Website is Empty
-
16-10-2019 - |
Question
I'm attempting to create a staging environment using Magento "Staging Website" feature that was include in 1.12 (System > Content Staging). However, after the initial set up is complete, all I'm left with is a new store view and a few empty files
staging/base_staging/.htaccess
staging/base_staging/index.php
I don't see anything in var/log
and have reindexed. My guess is that if these files are empty, it's obviously not going to do anything.
What could have prevented this from running correctly?
Solution
From Enterprise_Staging_Model_Entry
/**
* Create entry point if possible
*
* @return Enterprise_Staging_Model_Entry
*/
public function save()
{
$this->_ensureWebsite();
if ($this->canEntryPointBeCreated()) {
$sample = file_get_contents(BP . DS . 'index.php.sample');
$outputFile = $this->getFilename();
if (!is_dir(dirname($outputFile))) {
mkdir(dirname($outputFile));
}
$result = str_replace(
array('include $', 'app/Mage.php'),
array('include \'../../\' . $', '../../app/Mage.php'),
$sample
);
$result = preg_replace('/Mage::run\(.*?\)/us', "Mage::run('{$this->_website->getCode()}', 'website')", $result);
file_put_contents($outputFile, $result);
$sample = file_get_contents(BP . DS . '.htaccess.sample');
$search = <<<SEARCH
############################################
## workaround for HTTP authorization
## in CGI environment
SEARCH;
$replace = <<<REPLACE
############################################
## add 'no_cache' GET parameter for staging sites
RewriteCond %{QUERY_STRING} !(^|[?&])no_cache([&=]|$)
RewriteRule (.*) $1?no_cache [QSA]
############################################
## workaround for HTTP authorization
## in CGI environment
REPLACE;
$sample = str_replace($search, $replace, $sample);
$outputFile = $this->getBaseFolder() . DS . $this->_website->getCode() . DS . '.htaccess';
file_put_contents($outputFile, $sample);
}
return $this;
}
Make sure index.php.sample
and .htaccess.sample
exist. They are copied when creating a new staging environment.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange