Version Notes
Restored logic for only redirecting on noRoute 404.
Download this release
Release Info
| Developer | Arron Moss |
| Extension | Zero1_Seoredirects |
| Version | 1.0.13 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.10 to 1.0.13
app/code/community/Zero1/Seoredirects/Model/Observer.php
CHANGED
|
@@ -3,16 +3,19 @@ class Zero1_Seoredirects_Model_Observer
|
|
| 3 |
{
|
| 4 |
const DEFAULT_LIMIT = 50;
|
| 5 |
|
| 6 |
-
function
|
| 7 |
-
{
|
| 8 |
-
$
|
| 9 |
-
$request = $front->getRequest();
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
// First search for the URI with query strings
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
foreach($redirections as $redirection)
|
| 18 |
{
|
|
@@ -22,10 +25,10 @@ class Zero1_Seoredirects_Model_Observer
|
|
| 22 |
}
|
| 23 |
|
| 24 |
// Then search for the URI without query strings
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
foreach($redirections as $redirection)
|
| 31 |
{
|
|
@@ -38,6 +41,16 @@ class Zero1_Seoredirects_Model_Observer
|
|
| 38 |
return;
|
| 39 |
}
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
function updateRedirectionsCronJob()
|
| 42 |
{
|
| 43 |
$dump_path = Mage::getBaseDir('var').'/seoredirects';
|
|
@@ -98,6 +111,10 @@ class Zero1_Seoredirects_Model_Observer
|
|
| 98 |
$data[0] = preg_replace('/^http[s]*:\\/\\/[^\\/]+(.*)$/si', '$1', $data[0]);
|
| 99 |
$data[1] = preg_replace('/^http[s]*:\\/\\/[^\\/]+(.*)$/si', '$1', $data[1]);
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
$redirects[$data[0]] = $data[1];
|
| 102 |
}
|
| 103 |
}
|
|
@@ -178,10 +195,7 @@ class Zero1_Seoredirects_Model_Observer
|
|
| 178 |
{
|
| 179 |
if(!$redirectionA || !$redirectionB)
|
| 180 |
continue; // Invalid rediection, been deleted?
|
| 181 |
-
|
| 182 |
-
if($redirectionA == $redirectionB)
|
| 183 |
-
continue;
|
| 184 |
-
|
| 185 |
if($redirectionA->getRedirectTo() == $redirectionB->getRedirectFrom())
|
| 186 |
{
|
| 187 |
//echo 'Removed loop <b>'.$redirection->getRedirectFrom().'</b> from store ID <b>'.$store->getId().'</b><br/>';
|
| 3 |
{
|
| 4 |
const DEFAULT_LIMIT = 50;
|
| 5 |
|
| 6 |
+
function checkForRedirection(Varien_Event_Observer $observer)
|
| 7 |
+
{
|
| 8 |
+
$request = $observer->getFront()->getRequest();
|
|
|
|
| 9 |
|
| 10 |
+
if($request->getActionName() != 'noRoute')
|
| 11 |
+
return; // There is a valid route, nothing to do
|
| 12 |
+
|
| 13 |
// First search for the URI with query strings
|
| 14 |
+
$requestUri = preg_replace('/^'.preg_quote($request->getBasePath(), '/').'/', '', $request->getRequestUri());
|
| 15 |
+
$requestUri = str_replace('?', '_', $requestUri); // Zend does not support "?", replace them with "_" wildcard and use LIKE
|
| 16 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
| 17 |
+
$redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
|
| 18 |
+
$redirections->addFieldToFilter('redirect_from', array('like' => $requestUri));
|
| 19 |
|
| 20 |
foreach($redirections as $redirection)
|
| 21 |
{
|
| 25 |
}
|
| 26 |
|
| 27 |
// Then search for the URI without query strings
|
| 28 |
+
$requestUri = preg_replace('/^'.preg_quote($request->getBasePath(), '/').'/', '', $request->getRequestString());
|
| 29 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
| 30 |
+
$redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
|
| 31 |
+
$redirections->addFieldToFilter('redirect_from', $requestUri);
|
| 32 |
|
| 33 |
foreach($redirections as $redirection)
|
| 34 |
{
|
| 41 |
return;
|
| 42 |
}
|
| 43 |
|
| 44 |
+
function controller_front_send_response_before(Varien_Event_Observer $observer)
|
| 45 |
+
{
|
| 46 |
+
$this->checkForRedirection($observer);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function controller_front_send_response_after(Varien_Event_Observer $observer)
|
| 50 |
+
{
|
| 51 |
+
$this->checkForRedirection($observer);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
function updateRedirectionsCronJob()
|
| 55 |
{
|
| 56 |
$dump_path = Mage::getBaseDir('var').'/seoredirects';
|
| 111 |
$data[0] = preg_replace('/^http[s]*:\\/\\/[^\\/]+(.*)$/si', '$1', $data[0]);
|
| 112 |
$data[1] = preg_replace('/^http[s]*:\\/\\/[^\\/]+(.*)$/si', '$1', $data[1]);
|
| 113 |
|
| 114 |
+
// Strip the prefix slash from the FROM / TO URL's if it exists
|
| 115 |
+
$data[0] = preg_replace('/^\\/(.*)$/si', '$1', $data[0]);
|
| 116 |
+
$data[1] = preg_replace('/^\\/(.*)$/si', '$1', $data[1]);
|
| 117 |
+
|
| 118 |
$redirects[$data[0]] = $data[1];
|
| 119 |
}
|
| 120 |
}
|
| 195 |
{
|
| 196 |
if(!$redirectionA || !$redirectionB)
|
| 197 |
continue; // Invalid rediection, been deleted?
|
| 198 |
+
|
|
|
|
|
|
|
|
|
|
| 199 |
if($redirectionA->getRedirectTo() == $redirectionB->getRedirectFrom())
|
| 200 |
{
|
| 201 |
//echo 'Removed loop <b>'.$redirection->getRedirectFrom().'</b> from store ID <b>'.$store->getId().'</b><br/>';
|
app/code/community/Zero1/Seoredirects/etc/config.xml
CHANGED
|
@@ -58,16 +58,26 @@
|
|
| 58 |
</admin>
|
| 59 |
|
| 60 |
<frontend>
|
| 61 |
-
<events>
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
</events>
|
| 72 |
</frontend>
|
| 73 |
|
| 58 |
</admin>
|
| 59 |
|
| 60 |
<frontend>
|
| 61 |
+
<events>
|
| 62 |
+
<controller_front_send_response_before>
|
| 63 |
+
<observers>
|
| 64 |
+
<Zero1_Seoredirects_Model_Observer>
|
| 65 |
+
<type>singleton</type>
|
| 66 |
+
<class>Zero1_Seoredirects_Model_Observer</class>
|
| 67 |
+
<method>controller_front_send_response_before</method>
|
| 68 |
+
</Zero1_Seoredirects_Model_Observer>
|
| 69 |
+
</observers>
|
| 70 |
+
</controller_front_send_response_before>
|
| 71 |
+
|
| 72 |
+
<controller_front_send_response_after>
|
| 73 |
+
<observers>
|
| 74 |
+
<Zero1_Seoredirects_Model_Observer>
|
| 75 |
+
<type>singleton</type>
|
| 76 |
+
<class>Zero1_Seoredirects_Model_Observer</class>
|
| 77 |
+
<method>controller_front_send_response_after</method>
|
| 78 |
+
</Zero1_Seoredirects_Model_Observer>
|
| 79 |
+
</observers>
|
| 80 |
+
</controller_front_send_response_after>
|
| 81 |
</events>
|
| 82 |
</frontend>
|
| 83 |
|
package.xml
CHANGED
|
@@ -1,21 +1,18 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Zero1_Seoredirects</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Manage you SEO redirects using a Google Doc</summary>
|
| 10 |
<description>Manage you SEO redirects using a Google Doc</description>
|
| 11 |
-
<notes>
|
| 12 |
-

|
| 13 |
-
When searching for a URL match the module will now firstly search with the Query string on the URL then if not found search again for the URL without the query string.
|
| 14 |
-
</notes>
|
| 15 |
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
| 16 |
-
<date>2012-
|
| 17 |
-
<time>
|
| 18 |
-
<contents><target name="magecommunity"><dir name="Zero1"><dir name="Seoredirects"><dir name="Block"><dir name="Manage"><file name="Grid.php" hash="b06399e81b30ef592805277595061b38"/></dir><file name="Manage.php" hash="1ed89ca5e60aeec11a5c225bcce8e124"/></dir><dir name="Helper"><file name="Data.php" hash="36474aca2c8e7dce3f30c398bd9c0ce0"/><file name="License.php" hash="479affaec1ba20aa6b916dec4e055b4b"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Redirection"><file name="Collection.php" hash="a848d959fdca977b4470f46c93a27eb7"/></dir><file name="Redirection.php" hash="a357992dee4bb6cf526bb358dc4d1e0d"/><file name="Setup.php" hash="13c67d7925878d2076edcf92c375b9c1"/></dir><file name="Observer.php" hash="
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 21 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Zero1_Seoredirects</name>
|
| 4 |
+
<version>1.0.13</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Manage you SEO redirects using a Google Doc</summary>
|
| 10 |
<description>Manage you SEO redirects using a Google Doc</description>
|
| 11 |
+
<notes>Restored logic for only redirecting on noRoute 404.</notes>
|
|
|
|
|
|
|
|
|
|
| 12 |
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
| 13 |
+
<date>2012-11-21</date>
|
| 14 |
+
<time>10:52:19</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Zero1"><dir name="Seoredirects"><dir name="Block"><dir name="Manage"><file name="Grid.php" hash="b06399e81b30ef592805277595061b38"/></dir><file name="Manage.php" hash="1ed89ca5e60aeec11a5c225bcce8e124"/></dir><dir name="Helper"><file name="Data.php" hash="36474aca2c8e7dce3f30c398bd9c0ce0"/><file name="License.php" hash="479affaec1ba20aa6b916dec4e055b4b"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Redirection"><file name="Collection.php" hash="a848d959fdca977b4470f46c93a27eb7"/></dir><file name="Redirection.php" hash="a357992dee4bb6cf526bb358dc4d1e0d"/><file name="Setup.php" hash="13c67d7925878d2076edcf92c375b9c1"/></dir><file name="Observer.php" hash="14eedd686613a469bc5d45be41d14cd4"/><file name="Redirection.php" hash="8d26f395bf5b33679b032c160152e24a"/><dir name="Resource"><dir name="Redirection"><file name="Collection.php" hash="0b7bd678d49530782ba9198537ae5bc9"/></dir><file name="Redirection.php" hash="b2e5de0d116e2c17ecd3fb09472e4349"/><file name="Setup.php" hash="5d9dddc43a5bb75b68f1a2e4b98d36b6"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Seoredirects"><file name="ManageController.php" hash="bf497a1ce5f202abd024a5736a0e8a9a"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7e8d3a4c8dff9b4df9f380c284225393"/><file name="config.xml" hash="f33497c0d7bc204fd078761ded9c25e4"/><file name="system.xml" hash="90f9074a3ff17ea4a671f6554b28af92"/></dir><dir name="sql"><dir name="seoredirects_setup"><file name="install-1.0.0.php" hash="918bc1dee6bb2388e78b7346929916c9"/><file name="install-1.0.1.php" hash="918bc1dee6bb2388e78b7346929916c9"/><file name="mysql4-install-1.0.0.php" hash="918bc1dee6bb2388e78b7346929916c9"/><file name="mysql4-install-1.0.1.php" hash="918bc1dee6bb2388e78b7346929916c9"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_Seoredirects.xml" hash="dd176346dbb2abf0e20d8ea087abe2ce"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="seoredirects.xml" hash="84e2381a4d12eb22fa5e6b5b092ddef7"/></dir></dir></dir></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
