Zero1_Seoredirects - Version 1.0.10

Version Notes

At the point of inserting a URL in to the database from a feed the module will now strip the "http://www.domain.com" element from the URL if it exists.

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.

Download this release

Release Info

Developer Arron Moss
Extension Zero1_Seoredirects
Version 1.0.10
Comparing to
See all releases


Code changes from version 1.0.8 to 1.0.10

app/code/community/Zero1/Seoredirects/Model/Observer.php CHANGED
@@ -8,6 +8,20 @@ class Zero1_Seoredirects_Model_Observer
8
  $front = $observer->getFront();
9
  $request = $front->getRequest();
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  $requestUri = preg_replace('/^'.preg_quote($request->getBasePath(), '/').'/', '', $request->getRequestUri());
12
  $redirections = Mage::getModel('seoredirects/redirection')->getCollection();
13
  $redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
@@ -79,7 +93,13 @@ class Zero1_Seoredirects_Model_Observer
79
  while(($data = fgetcsv($fp, 4096)) !== false)
80
  {
81
  if(is_array($data) && count($data) >= 2)
 
 
 
 
 
82
  $redirects[$data[0]] = $data[1];
 
83
  }
84
  fclose($fp);
85
 
8
  $front = $observer->getFront();
9
  $request = $front->getRequest();
10
 
11
+ // First search for the URI with query strings
12
+ $requestUri = preg_replace('/^'.preg_quote($request->getBasePath(), '/').'/', '', $request->getRequestString());
13
+ $redirections = Mage::getModel('seoredirects/redirection')->getCollection();
14
+ $redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
15
+ $redirections->addFieldToFilter('redirect_from', $requestUri);
16
+
17
+ foreach($redirections as $redirection)
18
+ {
19
+ header('HTTP/1.1 301 Moved Permanently');
20
+ header('Location: '.$request->getBasePath().$redirection->getRedirectTo());
21
+ die();
22
+ }
23
+
24
+ // Then search for the URI without query strings
25
  $requestUri = preg_replace('/^'.preg_quote($request->getBasePath(), '/').'/', '', $request->getRequestUri());
26
  $redirections = Mage::getModel('seoredirects/redirection')->getCollection();
27
  $redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
93
  while(($data = fgetcsv($fp, 4096)) !== false)
94
  {
95
  if(is_array($data) && count($data) >= 2)
96
+ {
97
+ // Strip the domain name from the FROM / TO URL's if it exists
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
  }
104
  fclose($fp);
105
 
app/code/community/Zero1/Seoredirects/etc/system.xml CHANGED
@@ -5,14 +5,14 @@
5
  <label>SEO Redirect</label>
6
  <tab>catalog</tab>
7
  <sort_order>990</sort_order>
8
- <show_in_default>0</show_in_default>
9
  <show_in_website>1</show_in_website>
10
  <show_in_store>1</show_in_store>
11
  <groups>
12
  <settings translate="label">
13
  <label>SEO Redirect Settings</label>
14
  <sort_order>1</sort_order>
15
- <show_in_default>0</show_in_default>
16
  <show_in_website>1</show_in_website>
17
  <show_in_store>1</show_in_store>
18
  <fields>
@@ -21,8 +21,8 @@
21
  <frontend_type>select</frontend_type>
22
  <source_model>adminhtml/system_config_source_yesno</source_model>
23
  <sort_order>0</sort_order>
24
- <show_in_default>0</show_in_default>
25
- <show_in_website>0</show_in_website>
26
  <show_in_store>1</show_in_store>
27
  </enabled>
28
 
@@ -30,8 +30,8 @@
30
  <label>Google Docs URL</label>
31
  <frontend_type>text</frontend_type>
32
  <sort_order>1</sort_order>
33
- <show_in_default>0</show_in_default>
34
- <show_in_website>0</show_in_website>
35
  <show_in_store>1</show_in_store>
36
  <comment>The above URL will be downloaded into Magento at 2am every morning</comment>
37
  </url>
@@ -40,7 +40,7 @@
40
  <label>Serial</label>
41
  <frontend_type>textarea</frontend_type>
42
  <sort_order>2</sort_order>
43
- <show_in_default>0</show_in_default>
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>0</show_in_store>
46
  <comment><![CDATA[Visit <a href="http://www.zero1.co.uk/" target="_blank">http://www.zero1.co.uk</a> if you require a serial.]]></comment>
5
  <label>SEO Redirect</label>
6
  <tab>catalog</tab>
7
  <sort_order>990</sort_order>
8
+ <show_in_default>1</show_in_default>
9
  <show_in_website>1</show_in_website>
10
  <show_in_store>1</show_in_store>
11
  <groups>
12
  <settings translate="label">
13
  <label>SEO Redirect Settings</label>
14
  <sort_order>1</sort_order>
15
+ <show_in_default>1</show_in_default>
16
  <show_in_website>1</show_in_website>
17
  <show_in_store>1</show_in_store>
18
  <fields>
21
  <frontend_type>select</frontend_type>
22
  <source_model>adminhtml/system_config_source_yesno</source_model>
23
  <sort_order>0</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
  <show_in_store>1</show_in_store>
27
  </enabled>
28
 
30
  <label>Google Docs URL</label>
31
  <frontend_type>text</frontend_type>
32
  <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
  <show_in_store>1</show_in_store>
36
  <comment>The above URL will be downloaded into Magento at 2am every morning</comment>
37
  </url>
40
  <label>Serial</label>
41
  <frontend_type>textarea</frontend_type>
42
  <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>0</show_in_store>
46
  <comment><![CDATA[Visit <a href="http://www.zero1.co.uk/" target="_blank">http://www.zero1.co.uk</a> if you require a serial.]]></comment>
package.xml CHANGED
@@ -1,18 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Zero1_Seoredirects</name>
4
- <version>1.0.8</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>Fixed an issue with the table not being created when installing.</notes>
 
 
 
12
  <authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
13
- <date>2012-10-22</date>
14
- <time>12:17:49</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="5cb45e14d9c45f2ec35ab1f1c4d2ab80"/><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="32ba23bb8f95679fa57126bdc880ffbc"/><file name="system.xml" hash="063dab03c71e04400c1f469b4f15ad61"/></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Zero1_Seoredirects</name>
4
+ <version>1.0.10</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>At the point of inserting a URL in to the database from a feed the module will now strip the "http://www.domain.com" element from the URL if it exists.&#xD;
12
+ &#xD;
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.&#xD;
14
+ </notes>
15
  <authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
16
+ <date>2012-10-24</date>
17
+ <time>14:03:41</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="b6fcec8c06b6338d3ffc9c538b4ad7c3"/><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="32ba23bb8f95679fa57126bdc880ffbc"/><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>
19
  <compatible/>
20
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>