Version Notes
First release.
Download this release
Release Info
Developer | Arron Moss |
Extension | Zero1_Seoredirects |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Zero1/Seoredirects/Block/Manage.php +21 -0
- app/code/community/Zero1/Seoredirects/Block/Manage/Grid.php +61 -0
- app/code/community/Zero1/Seoredirects/Helper/Data.php +8 -0
- app/code/community/Zero1/Seoredirects/Model/Mysql4/Redirection.php +8 -0
- app/code/community/Zero1/Seoredirects/Model/Mysql4/Redirection/Collection.php +8 -0
- app/code/community/Zero1/Seoredirects/Model/Mysql4/Setup.php +5 -0
- app/code/community/Zero1/Seoredirects/Model/Observer.php +158 -0
- app/code/community/Zero1/Seoredirects/Model/Redirection.php +8 -0
- app/code/community/Zero1/Seoredirects/controllers/Adminhtml/Seoredirects/ManageController.php +45 -0
- app/code/community/Zero1/Seoredirects/etc/adminhtml.xml +41 -0
- app/code/community/Zero1/Seoredirects/etc/config.xml +105 -0
- app/code/community/Zero1/Seoredirects/etc/system.xml +43 -0
- app/code/community/Zero1/Seoredirects/sql/seoredirects_setup/mysql4-install-1.0.0.php +19 -0
- app/design/adminhtml/default/default/layout/seoredirects.xml +13 -0
- app/etc/modules/Zero1_Seoredirects.xml +11 -0
- package.xml +18 -0
app/code/community/Zero1/Seoredirects/Block/Manage.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Block_Manage extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
protected $_controller = 'seoredirects';
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_controller = 'manage';
|
9 |
+
$this->_blockGroup = 'seoredirects';
|
10 |
+
|
11 |
+
$this->_headerText = Mage::helper('seoredirects')->__('SEO Redirection Management');
|
12 |
+
$this->_addButton('refresh', array(
|
13 |
+
'label' => $this->__('Refresh from Google'),
|
14 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/update')}')",
|
15 |
+
'class' => 'refresh'
|
16 |
+
));
|
17 |
+
|
18 |
+
parent::__construct();
|
19 |
+
$this->_removeButton('add');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Zero1/Seoredirects/Block/Manage/Grid.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Block_Manage_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('manageGrid');
|
8 |
+
$this->setDefaultSort('entity_id');
|
9 |
+
}
|
10 |
+
|
11 |
+
protected function _getStore()
|
12 |
+
{
|
13 |
+
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
14 |
+
return Mage::app()->getStore($storeId);
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _prepareCollection()
|
18 |
+
{
|
19 |
+
$store = $this->_getStore();
|
20 |
+
|
21 |
+
$collection = Mage::getModel('seoredirects/redirection')->getCollection();
|
22 |
+
|
23 |
+
if($store->getId())
|
24 |
+
{
|
25 |
+
$collection->addFieldToFilter('store', $store->getId());
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->setCollection($collection);
|
29 |
+
|
30 |
+
return parent::_prepareCollection();
|
31 |
+
}
|
32 |
+
|
33 |
+
protected function _prepareColumns()
|
34 |
+
{
|
35 |
+
$this->addColumn('entity_id', array(
|
36 |
+
'header' => Mage::helper('catalog')->__('ID'),
|
37 |
+
'sortable' => true,
|
38 |
+
'width' => '60',
|
39 |
+
'index' => 'entity_id'
|
40 |
+
));
|
41 |
+
|
42 |
+
$this->addColumn('redirect_from', array(
|
43 |
+
'header' => Mage::helper('catalog')->__('From'),
|
44 |
+
'index' => 'redirect_from'
|
45 |
+
));
|
46 |
+
|
47 |
+
$this->addColumn('redirect_to', array(
|
48 |
+
'header' => Mage::helper('catalog')->__('To'),
|
49 |
+
'index' => 'redirect_to'
|
50 |
+
));
|
51 |
+
|
52 |
+
$this->addColumn('store', array(
|
53 |
+
'header' => Mage::helper('newsletter')->__('Store'),
|
54 |
+
'index' => 'store',
|
55 |
+
'type' => 'options',
|
56 |
+
'options' => Mage::getModel('adminhtml/system_store')->getStoreOptionHash()
|
57 |
+
));
|
58 |
+
|
59 |
+
return parent::_prepareColumns();
|
60 |
+
}
|
61 |
+
}
|
app/code/community/Zero1/Seoredirects/Helper/Data.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Zero1/Seoredirects/Model/Mysql4/Redirection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Model_Mysql4_Redirection extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('seoredirects/redirection', 'entity_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Zero1/Seoredirects/Model/Mysql4/Redirection/Collection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Model_Mysql4_Redirection_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('seoredirects/redirection');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Zero1/Seoredirects/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/Zero1/Seoredirects/Model/Observer.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Model_Observer
|
3 |
+
{
|
4 |
+
function controller_front_send_response_before(Varien_Event_Observer $observer)
|
5 |
+
{
|
6 |
+
$front = $observer->getFront();
|
7 |
+
$request = $front->getRequest();
|
8 |
+
|
9 |
+
if($request->getActionName() != 'noRoute')
|
10 |
+
return; // There is a valid route, nothing to do
|
11 |
+
|
12 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
13 |
+
$redirections->addFieldToFilter('store', Mage::app()->getStore()->getId());
|
14 |
+
$redirections->addFieldToFilter('redirect_from', $request->getRequestString());
|
15 |
+
|
16 |
+
foreach($redirections as $redirection)
|
17 |
+
{
|
18 |
+
header('HTTP/1.1 301 Moved Permanently');
|
19 |
+
header('Location: '.$redirection->getRedirectTo());
|
20 |
+
die();
|
21 |
+
}
|
22 |
+
|
23 |
+
// No redirections
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
function updateRedirectionsCronJob()
|
28 |
+
{
|
29 |
+
$dump_path = Mage::getBaseDir('var').'/seoredirects';
|
30 |
+
if(!file_exists($dump_path))
|
31 |
+
mkdir($dump_path);
|
32 |
+
|
33 |
+
$stores = Mage::getResourceModel('core/store_collection');
|
34 |
+
|
35 |
+
$updated = 0;
|
36 |
+
$added = 0;
|
37 |
+
$deleted = 0;
|
38 |
+
$loops = 0;
|
39 |
+
|
40 |
+
foreach($stores as $store)
|
41 |
+
{
|
42 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
43 |
+
$redirections->addFieldToFilter('store', $store->getId());
|
44 |
+
|
45 |
+
if(!Mage::getStoreConfig('seoredirects/settings/seoredirects_enabled', $store->getId()))
|
46 |
+
{
|
47 |
+
// Redirects are disabled for this store, delete them all
|
48 |
+
foreach($redirections as $redirection)
|
49 |
+
{
|
50 |
+
$redirection->delete();
|
51 |
+
$deleted++;
|
52 |
+
}
|
53 |
+
|
54 |
+
continue; // Do not import anything now
|
55 |
+
}
|
56 |
+
|
57 |
+
$url = Mage::getStoreConfig('seoredirects/settings/seoredirects_url', $store->getId());
|
58 |
+
|
59 |
+
if(empty($url))
|
60 |
+
continue; // Invalid URL, do not update the existing data
|
61 |
+
|
62 |
+
$client = new Zend_Http_Client($url);
|
63 |
+
|
64 |
+
$filename = $store->getId().'-'.time().'.csv';
|
65 |
+
touch($dump_path.'/'.$filename);
|
66 |
+
|
67 |
+
$fp = fopen($dump_path.'/'.$filename, 'r+');
|
68 |
+
fwrite($fp, $client->request()->getBody());
|
69 |
+
fseek($fp, 0);
|
70 |
+
|
71 |
+
////////////////////////////////////////////////
|
72 |
+
// Import the new redirections
|
73 |
+
$redirects = array();
|
74 |
+
|
75 |
+
while(($data = fgetcsv($fp, 4096)) !== false)
|
76 |
+
{
|
77 |
+
if(is_array($data) && count($data) >= 2)
|
78 |
+
$redirects[$data[0]] = $data[1];
|
79 |
+
}
|
80 |
+
fclose($fp);
|
81 |
+
|
82 |
+
// Add / update the redirections
|
83 |
+
foreach($redirects as $from => $to)
|
84 |
+
{
|
85 |
+
$found = false;
|
86 |
+
|
87 |
+
foreach($redirections as $redirection)
|
88 |
+
{
|
89 |
+
if($redirection->getRedirectFrom() == $from)
|
90 |
+
{
|
91 |
+
// Existing redirection, update
|
92 |
+
$redirection->setRedirectTo($to);
|
93 |
+
$redirection->setRedirectFrom($from);
|
94 |
+
$redirection->setStore($store->getId());
|
95 |
+
$redirection->save();
|
96 |
+
$found = true;
|
97 |
+
$updated++;
|
98 |
+
|
99 |
+
//echo 'Updated <b>'.$from.'</b> = <b>'.$to.'</b> into store ID <b>'.$store->getId().'</b><br/>';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
if(!$found)
|
104 |
+
{
|
105 |
+
// New redirection
|
106 |
+
$redirection = Mage::getModel('seoredirects/redirection');
|
107 |
+
$redirection->setRedirectTo($to);
|
108 |
+
$redirection->setRedirectFrom($from);
|
109 |
+
$redirection->setStore($store->getId());
|
110 |
+
$redirection->save();
|
111 |
+
$added++;
|
112 |
+
|
113 |
+
//echo 'Added <b>'.$from.'</b> = <b>'.$to.'</b> into store ID <b>'.$store->getId().'</b><br/>';
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
// Remove all the unused redirections
|
118 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
119 |
+
$redirections->addFieldToFilter('store', $store->getId());
|
120 |
+
foreach($redirections as $redirection)
|
121 |
+
{
|
122 |
+
if(!array_key_exists($redirection->getRedirectFrom(), $redirects))
|
123 |
+
{
|
124 |
+
//echo 'Removed <b>'.$redirection->getRedirectFrom().'</b> from store ID <b>'.$store->getId().'</b><br/>';
|
125 |
+
$redirection->delete();
|
126 |
+
$deleted++;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
// Make sure there are no redirection loops
|
131 |
+
$redirections = Mage::getModel('seoredirects/redirection')->getCollection();
|
132 |
+
$redirections->addFieldToFilter('store', $store->getId());
|
133 |
+
foreach($redirections as $redirectionA)
|
134 |
+
{
|
135 |
+
foreach($redirections as $redirectionB)
|
136 |
+
{
|
137 |
+
if(!$redirectionA || !$redirectionB)
|
138 |
+
continue; // Invalid rediection, been deleted?
|
139 |
+
|
140 |
+
if($redirectionA == $redirectionB)
|
141 |
+
continue;
|
142 |
+
|
143 |
+
if($redirectionA->getRedirectTo() == $redirectionB->getRedirectFrom())
|
144 |
+
{
|
145 |
+
//echo 'Removed loop <b>'.$redirection->getRedirectFrom().'</b> from store ID <b>'.$store->getId().'</b><br/>';
|
146 |
+
$redirectionA->delete();
|
147 |
+
$loops++;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
Mage::register('seoredirects_updated', $updated);
|
154 |
+
Mage::register('seoredirects_added', $added);
|
155 |
+
Mage::register('seoredirects_deleted', $deleted);
|
156 |
+
Mage::register('seoredirects_loops', $loops);
|
157 |
+
}
|
158 |
+
}
|
app/code/community/Zero1/Seoredirects/Model/Redirection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Model_Redirection extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('seoredirects/redirection');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Zero1/Seoredirects/controllers/Adminhtml/Seoredirects/ManageController.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Zero1_Seoredirects_Adminhtml_Seoredirects_ManageController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->_title($this->__('SEO Redirects'))
|
7 |
+
->_title($this->__('Manage Redirects'));
|
8 |
+
|
9 |
+
$this->loadLayout();
|
10 |
+
$this->_setActiveMenu('catalog/seoredirects');
|
11 |
+
$this->renderLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
public function updateAction()
|
15 |
+
{
|
16 |
+
Mage::getModel('seoredirects/observer')->updateRedirectionsCronJob();
|
17 |
+
|
18 |
+
$updated = Mage::registry('seoredirects_updated');
|
19 |
+
$added = Mage::registry('seoredirects_added');
|
20 |
+
$deleted = Mage::registry('seoredirects_deleted');
|
21 |
+
$loops = Mage::registry('seoredirects_loops');
|
22 |
+
|
23 |
+
if($updated > 0)
|
24 |
+
$this->_getSession()->addSuccess(
|
25 |
+
Mage::helper('seoredirects')->__('Updated '.$updated.' redirection(s).')
|
26 |
+
);
|
27 |
+
|
28 |
+
if($added > 0)
|
29 |
+
$this->_getSession()->addSuccess(
|
30 |
+
Mage::helper('seoredirects')->__('Added '.$added.' redirection(s).')
|
31 |
+
);
|
32 |
+
|
33 |
+
if($deleted > 0)
|
34 |
+
$this->_getSession()->addSuccess(
|
35 |
+
Mage::helper('seoredirects')->__('Deleted '.$deleted.' redirection(s).')
|
36 |
+
);
|
37 |
+
|
38 |
+
if($loops > 0)
|
39 |
+
$this->_getSession()->addSuccess(
|
40 |
+
Mage::helper('seoredirects')->__('Deleted '.$loops.' looping redirection(s).')
|
41 |
+
);
|
42 |
+
|
43 |
+
$this->_redirect('*/*/index');
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Zero1/Seoredirects/etc/adminhtml.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<catalog>
|
5 |
+
<children>
|
6 |
+
<seoredirects translate="title" module="seoredirects">
|
7 |
+
<title>SEO Redirects</title>
|
8 |
+
<sort_order>60</sort_order>
|
9 |
+
<!-- action>adminhtml/seoredirects/</action -->
|
10 |
+
<children>
|
11 |
+
<seoredirects_manage translate="title" module="seoredirects">
|
12 |
+
<title>Manage Redirections</title>
|
13 |
+
<action>adminhtml/seoredirects_manage/index</action>
|
14 |
+
<sort_order>0</sort_order>
|
15 |
+
</seoredirects_manage>
|
16 |
+
</children>
|
17 |
+
</seoredirects>
|
18 |
+
</children>
|
19 |
+
</catalog>
|
20 |
+
</menu>
|
21 |
+
|
22 |
+
<acl>
|
23 |
+
<resources>
|
24 |
+
<admin>
|
25 |
+
<children>
|
26 |
+
<system>
|
27 |
+
<children>
|
28 |
+
<config>
|
29 |
+
<children>
|
30 |
+
<seoredirects translate="title" module="seoredirects">
|
31 |
+
<title>SEO Redirect</title>
|
32 |
+
</seoredirects>
|
33 |
+
</children>
|
34 |
+
</config>
|
35 |
+
</children>
|
36 |
+
</system>
|
37 |
+
</children>
|
38 |
+
</admin>
|
39 |
+
</resources>
|
40 |
+
</acl>
|
41 |
+
</config>
|
app/code/community/Zero1/Seoredirects/etc/config.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Zero1_Seoredirects>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Zero1_Seoredirects>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<seoredirects>
|
12 |
+
<class>Zero1_Seoredirects_Model</class>
|
13 |
+
<resourceModel>seoredirects_mysql4</resourceModel>
|
14 |
+
</seoredirects>
|
15 |
+
|
16 |
+
<seoredirects_mysql4>
|
17 |
+
<class>Zero1_Seoredirects_Model_Mysql4</class>
|
18 |
+
<entities>
|
19 |
+
<redirection>
|
20 |
+
<table>zero1_seoredirects_redirection</table>
|
21 |
+
</redirection>
|
22 |
+
</entities>
|
23 |
+
</seoredirects_mysql4>
|
24 |
+
</models>
|
25 |
+
|
26 |
+
<resources>
|
27 |
+
<seoredirects_setup>
|
28 |
+
<setup>
|
29 |
+
<module>Zero1_Seoredirects</module>
|
30 |
+
<class>Zero1_Seoredirects_Model_Mysql4_Setup</class>
|
31 |
+
</setup>
|
32 |
+
</seoredirects_setup>
|
33 |
+
</resources>
|
34 |
+
|
35 |
+
<blocks>
|
36 |
+
<seoredirects>
|
37 |
+
<class>Zero1_Seoredirects_Block</class>
|
38 |
+
</seoredirects>
|
39 |
+
</blocks>
|
40 |
+
|
41 |
+
<helpers>
|
42 |
+
<seoredirects>
|
43 |
+
<class>Zero1_Seoredirects_Helper</class>
|
44 |
+
</seoredirects>
|
45 |
+
</helpers>
|
46 |
+
</global>
|
47 |
+
|
48 |
+
<admin>
|
49 |
+
<routers>
|
50 |
+
<adminhtml>
|
51 |
+
<args>
|
52 |
+
<modules>
|
53 |
+
<seoredirects before="Mage_Adminhtml">Zero1_Seoredirects_Adminhtml</seoredirects>
|
54 |
+
</modules>
|
55 |
+
</args>
|
56 |
+
</adminhtml>
|
57 |
+
</routers>
|
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 |
+
</events>
|
72 |
+
</frontend>
|
73 |
+
|
74 |
+
<adminhtml>
|
75 |
+
<layout>
|
76 |
+
<updates>
|
77 |
+
<seoredirects>
|
78 |
+
<file>seoredirects.xml</file>
|
79 |
+
</seoredirects>
|
80 |
+
</updates>
|
81 |
+
</layout>
|
82 |
+
</adminhtml>
|
83 |
+
|
84 |
+
<default>
|
85 |
+
<seoredirects>
|
86 |
+
<settings>
|
87 |
+
<seoredirects_enabled>0</seoredirects_enabled>
|
88 |
+
<seoredirects_url><![CDATA[https://docs.google.com/spreadsheet/pub?key=YOUR_OWN_KEY&single=true&gid=0&output=csv]]></seoredirects_url>
|
89 |
+
</settings>
|
90 |
+
</seoredirects>
|
91 |
+
</default>
|
92 |
+
|
93 |
+
<crontab>
|
94 |
+
<jobs>
|
95 |
+
<seoredirects>
|
96 |
+
<schedule>
|
97 |
+
<cron_expr>0 2 * * *</cron_expr>
|
98 |
+
</schedule>
|
99 |
+
<run>
|
100 |
+
<model>seoredirects/observer::updateRedirectionsCronJob</model>
|
101 |
+
</run>
|
102 |
+
</seoredirects>
|
103 |
+
</jobs>
|
104 |
+
</crontab>
|
105 |
+
</config>
|
app/code/community/Zero1/Seoredirects/etc/system.xml
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<seoredirects translate="label" module="seoredirects">
|
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>
|
19 |
+
<seoredirects_enabled translate="label">
|
20 |
+
<label>Enabled</label>
|
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 |
+
</seoredirects_enabled>
|
28 |
+
|
29 |
+
<seoredirects_url translate="label">
|
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 |
+
</seoredirects_url>
|
38 |
+
</fields>
|
39 |
+
</settings>
|
40 |
+
</groups>
|
41 |
+
</seoredirects>
|
42 |
+
</sections>
|
43 |
+
</config>
|
app/code/community/Zero1/Seoredirects/sql/seoredirects_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$installer->run("
|
7 |
+
|
8 |
+
DROP TABLE IF EXISTS {$this->getTable('zero1_seoredirects_redirection')};
|
9 |
+
CREATE TABLE {$this->getTable('zero1_seoredirects_redirection')} (
|
10 |
+
`entity_id` int(11) unsigned NOT NULL auto_increment,
|
11 |
+
`redirect_from` varchar(255) NOT NULL,
|
12 |
+
`redirect_to` varchar(255) NOT NULL,
|
13 |
+
`store` int(4) NOT NULL,
|
14 |
+
PRIMARY KEY (`entity_id`)
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
16 |
+
|
17 |
+
");
|
18 |
+
|
19 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/seoredirects.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_seoredirects_manage_index>
|
4 |
+
<reference name="content">
|
5 |
+
<!--
|
6 |
+
<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
|
7 |
+
<action method="setUseConfirm"><params>0</params></action>
|
8 |
+
</block>
|
9 |
+
-->
|
10 |
+
<block type="seoredirects/manage" name="seoredirects_manage"></block>
|
11 |
+
</reference>
|
12 |
+
</adminhtml_seoredirects_manage_index>
|
13 |
+
</layout>
|
app/etc/modules/Zero1_Seoredirects.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Zero1_Seoredirects>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
</depends>
|
9 |
+
</Zero1_Seoredirects>
|
10 |
+
</modules>
|
11 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Zero1_Seoredirects</name>
|
4 |
+
<version>1.0.0</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>First release.</notes>
|
12 |
+
<authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
|
13 |
+
<date>2012-05-11</date>
|
14 |
+
<time>11:49:03</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="67c1c6be8335c06d699f96c4387129b5"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Redirection"><file name="Collection.php" hash="73bf6b8f2ddff49dac520a6f71f72502"/></dir><file name="Redirection.php" hash="21d829342e13727de44bd3c821054bd9"/><file name="Setup.php" hash="e97a5f05e8459f367c14e98e7a0b03c6"/></dir><file name="Observer.php" hash="274530b6c18c67032ec424a5a91cf452"/><file name="Redirection.php" hash="8d26f395bf5b33679b032c160152e24a"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Seoredirects"><file name="ManageController.php" hash="3990bc42e66fdd278ab6f45904902d56"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7e8d3a4c8dff9b4df9f380c284225393"/><file name="config.xml" hash="c2c33f57c4969200128f82ac063b7336"/><file name="system.xml" hash="f1eea17fce3ee314c107c8aac921e9cd"/></dir><dir name="sql"><dir name="seoredirects_setup"><file name="mysql4-install-1.0.0.php" hash="5b0366b605c861c2ae6ee5f30d1eb744"/></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><extension><name>ionCube Loader</name><min></min><max></max></extension></required></dependencies>
|
18 |
+
</package>
|