MultiLanguage_Sitemap - Version 1.0.3

Version Notes

First Stable Version for General Use of the Multi-Language Optimization (hreflang).

This version properly configured automatically generates a multi-language sitemap supported by Google.

Download this release

Release Info

Developer Elie Orgel
Extension MultiLanguage_Sitemap
Version 1.0.3
Comparing to
See all releases


Version 1.0.3

app/code/local/Harapartners/SitemapXml/Block/Adminhtml/Language/Edit.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_SitemapXml_Block_Adminhtml_Language_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
14
+ {
15
+
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+
20
+ $this->_objectId = 'language_id';
21
+ $this->_blockGroup = 'sitemapxml';
22
+ $this->_controller = 'adminhtml_Language';
23
+
24
+ $this->_updateButton('save', 'label', Mage::helper('sitemapxml')->__('Save Language Map'));
25
+ $this->_updateButton('delete', 'label', Mage::helper('sitemapxml')->__('Delete Language Map'));
26
+ }
27
+
28
+ public function getHeaderText()
29
+ {
30
+ if (Mage::registry('sitemapxml_language_data') && Mage::registry('sitemapxml_language_data')->getId()) {
31
+ return Mage::helper('sitemapxml')->__('Edit Record Map');
32
+ } else {
33
+ return Mage::helper('sitemapxml')->__('Add Record Map');
34
+ }
35
+ }
36
+
37
+ protected function _prepareLayout()
38
+ {
39
+ $this->setChild('back_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
40
+ 'label' => Mage::helper('sitemapxml')->__('Back') ,
41
+ 'onclick' => "setLocation('" . $this->getUrl('*/*/index') . "')" ,
42
+ 'class' => 'back'
43
+ )));
44
+
45
+ return parent::_prepareLayout();
46
+ }
47
+
48
+ public function getBackButtonHtml()
49
+ {
50
+ return $this->getChildHtml('back_button');
51
+ }
52
+
53
+ public function getSaveUrl()
54
+ {
55
+ return $this->getUrl('*/*/save', array(
56
+ '_current' => true
57
+ ));
58
+ }
59
+
60
+ }
app/code/local/Harapartners/SitemapXml/Block/Adminhtml/Language/Edit/Form.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_SitemapXml_Block_Adminhtml_Language_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
14
+ {
15
+
16
+ protected function _prepareForm()
17
+ {
18
+ $yesno = Mage::getModel('adminhtml/system_config_source_yesno');
19
+
20
+ $form = new Varien_Data_Form(array(
21
+ 'id' => 'edit_form' ,
22
+ 'action' => $this->getData('action') ,
23
+ 'method' => 'post'
24
+ ));
25
+
26
+ // -------------------------------- Basic Info -------------------------------- //
27
+ $fieldsetIds = $form->addFieldset('language', array(
28
+ 'legend' => Mage::helper('sitemapxml')->__('Language Map Info')
29
+ ));
30
+
31
+ $fieldsetIds->addField('language_id', 'label', array(
32
+ 'label' => Mage::helper('sitemapxml')->__('Language Map ID') ,
33
+ 'name' => 'language_id' ,
34
+ 'required' => true
35
+ ));
36
+
37
+ $fieldsetIds->addField('store_view_id', 'select', array(
38
+ 'label' => Mage::helper('sitemapxml')->__('Record Map Status'),
39
+ 'name' => 'store_view_id',
40
+ 'values' => Mage::getModel('sitemapxml/source_store')->toOptionArray(),
41
+ 'required' => true
42
+ ));
43
+
44
+ $fieldsetIds->addField('language_code', 'text', array(
45
+ 'label' => Mage::helper('sitemapxml')->__('Language Code') ,
46
+ 'name' => 'language_code',
47
+ 'required' => true
48
+ ));
49
+
50
+
51
+ if (Mage::registry('sitemapxml_language_data')) {
52
+ $form->setValues(Mage::registry('sitemapxml_language_data')->getData());
53
+ } elseif ($recordData = Mage::getSingleton('adminhtml/session')->getData('sitemapxml_language_data')) {
54
+ $form->setValues($recordData);
55
+ Mage::getSingleton('adminhtml/session')->setData('sitemapxml_language_data', null);
56
+ }
57
+
58
+ $form->setUseContainer(true);
59
+ $this->setForm($form);
60
+ return parent::_prepareForm();
61
+ }
62
+ }
app/code/local/Harapartners/SitemapXml/Block/Adminhtml/Language/Index.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_SitemapXml_Block_Adminhtml_Language_Index extends Mage_Adminhtml_Block_Widget_Grid_Container {
14
+ /**
15
+ * Constructor
16
+ */
17
+ public function __construct() {
18
+ parent::__construct ();
19
+ $this->_blockGroup = 'sitemapxml';
20
+ $this->_controller = 'adminhtml_language_index';
21
+ $this->_headerText = Mage::helper ( 'sitemapxml' )->__ ( 'Langauge Map Entries' );
22
+ }
23
+ }
app/code/local/Harapartners/SitemapXml/Block/Adminhtml/Language/Index/Grid.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_SitemapXml_Block_Adminhtml_Language_Index_Grid extends Mage_Adminhtml_Block_Widget_Grid
14
+ {
15
+
16
+ public function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->setId('netsuiteLanguageGrid');
20
+ }
21
+
22
+ protected function _prepareCollection()
23
+ {
24
+ $model = Mage::getModel('sitemapxml/language');
25
+ $collection = $model->getCollection();
26
+ $this->setCollection($collection);
27
+ parent::_prepareCollection();
28
+ return $this;
29
+ }
30
+
31
+ protected function _getStore()
32
+ {
33
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
34
+ return Mage::app()->getStore($storeId);
35
+ }
36
+
37
+ protected function _prepareColumns()
38
+ {
39
+ $this->addColumn('language_id', array(
40
+ 'header' => Mage::helper('sitemapxml')->__('Language Map ID') ,
41
+ 'align' => 'right' ,
42
+ 'width' => '50px' ,
43
+ 'index' => 'language_id'
44
+ ));
45
+
46
+ $this->addColumn('store_view_id', array(
47
+ 'header' => Mage::helper('sitemapxml')->__('Store View Id') ,
48
+ 'align' => 'right' ,
49
+ 'width' => '50px' ,
50
+ 'index' => 'store_view_id' ,
51
+ 'type' => 'options' ,
52
+ 'options' => Mage::getModel('sitemapxml/source_store')->getStoreIds()
53
+ ));
54
+
55
+ $this->addColumn('language_code', array(
56
+ 'header' => Mage::helper('sitemapxml')->__('Language Code') ,
57
+ 'align' => 'right' ,
58
+ 'width' => '50px' ,
59
+ 'index' => 'language_code'
60
+ ));
61
+
62
+ return parent::_prepareColumns();
63
+ }
64
+
65
+ public function getRowUrl($row)
66
+ {
67
+ return $this->getUrl('*/*/edit', array(
68
+ 'store' => $this->getRequest()->getParam('store') ,
69
+ 'id' => $row->getId()
70
+ ));
71
+ }
72
+
73
+ }
app/code/local/Harapartners/SitemapXml/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SitemapXml_Helper_Data extends Mage_Core_Helper_Abstract
14
+ {
15
+ const XML_PATH_SITEMAP_IS_ENABLED = 'sitemap/language/is_enabled';
16
+
17
+ public function isLanguageEnabled()
18
+ {
19
+ return (boolean) Mage::getStoreConfig(self::XML_PATH_SITEMAP_IS_ENABLED);
20
+ }
21
+ }
app/code/local/Harapartners/SitemapXml/Helper/Rewrite/Adminhtml/Catalog.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml Catalog helper
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Harapartners_SitemapXml_Helper_Rewrite_Adminhtml_Catalog extends Mage_Adminhtml_Helper_Catalog
35
+ {
36
+
37
+ /**
38
+ * Get list valid paths for generate a sitemap XML file
39
+ *
40
+ * @return array
41
+ */
42
+ public function getSitemapValidPaths()
43
+ {
44
+ $path = parent::getSitemapValidPaths();
45
+ if (Mage::helper('sitemapxml')->isLanguageEnabled()) {
46
+ $path['available']['langauge'] = '/*/language.xml';
47
+ }
48
+
49
+ return $path;
50
+ }
51
+ }
app/code/local/Harapartners/SitemapXml/Model/Language.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SitemapXml_Model_Language extends Mage_Core_Model_Abstract
14
+ {
15
+
16
+ protected function _construct()
17
+ {
18
+ $this->_init('sitemapxml/language');
19
+ }
20
+ }
app/code/local/Harapartners/SitemapXml/Model/Resource/Catalog/Product.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sitemap
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Sitemap resource product collection model
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Sitemap
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Mage_Sitemap_Model_Resource_Catalog_Product extends Mage_Core_Model_Resource_Db_Abstract
36
+ {
37
+ /**
38
+ * Collection Zend Db select
39
+ *
40
+ * @var Zend_Db_Select
41
+ */
42
+ protected $_select;
43
+
44
+ /**
45
+ * Attribute cache
46
+ *
47
+ * @var array
48
+ */
49
+ protected $_attributesCache = array();
50
+
51
+ /**
52
+ * Init resource model (catalog/category)
53
+ *
54
+ */
55
+ protected function _construct()
56
+ {
57
+ $this->_init('catalog/product', 'entity_id');
58
+ }
59
+
60
+ /**
61
+ * Add attribute to filter
62
+ *
63
+ * @param int $storeId
64
+ * @param string $attributeCode
65
+ * @param mixed $value
66
+ * @param string $type
67
+ * @return Zend_Db_Select
68
+ */
69
+ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
70
+ {
71
+ if (!isset($this->_attributesCache[$attributeCode])) {
72
+ $attribute = Mage::getSingleton('catalog/product')->getResource()->getAttribute($attributeCode);
73
+
74
+ $this->_attributesCache[$attributeCode] = array(
75
+ 'entity_type_id' => $attribute->getEntityTypeId(),
76
+ 'attribute_id' => $attribute->getId(),
77
+ 'table' => $attribute->getBackend()->getTable(),
78
+ 'is_global' => $attribute->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
79
+ 'backend_type' => $attribute->getBackendType()
80
+ );
81
+ }
82
+
83
+ $attribute = $this->_attributesCache[$attributeCode];
84
+
85
+ if (!$this->_select instanceof Zend_Db_Select) {
86
+ return false;
87
+ }
88
+
89
+ switch ($type) {
90
+ case '=':
91
+ $conditionRule = '=?';
92
+ break;
93
+ case 'in':
94
+ $conditionRule = ' IN(?)';
95
+ break;
96
+ default:
97
+ return false;
98
+ break;
99
+ }
100
+
101
+ if ($attribute['backend_type'] == 'static') {
102
+ $this->_select->where('e.' . $attributeCode . $conditionRule, $value);
103
+ } else {
104
+ $this->_select->join(
105
+ array('t1_'.$attributeCode => $attribute['table']),
106
+ 'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0',
107
+ array()
108
+ )
109
+ ->where('t1_'.$attributeCode.'.attribute_id=?', $attribute['attribute_id']);
110
+
111
+ if ($attribute['is_global']) {
112
+ $this->_select->where('t1_'.$attributeCode.'.value'.$conditionRule, $value);
113
+ } else {
114
+ $ifCase = $this->_select->getAdapter()->getCheckSql('t2_'.$attributeCode.'.value_id > 0', 't2_'.$attributeCode.'.value', 't1_'.$attributeCode.'.value');
115
+ $this->_select->joinLeft(
116
+ array('t2_'.$attributeCode => $attribute['table']),
117
+ $this->_getWriteAdapter()->quoteInto('t1_'.$attributeCode.'.entity_id = t2_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.attribute_id = t2_'.$attributeCode.'.attribute_id AND t2_'.$attributeCode.'.store_id=?', $storeId),
118
+ array()
119
+ )
120
+ ->where('('.$ifCase.')'.$conditionRule, $value);
121
+ }
122
+ }
123
+
124
+ return $this->_select;
125
+ }
126
+
127
+ /**
128
+ * Get category collection array
129
+ *
130
+ * @param unknown_type $storeId
131
+ * @return array
132
+ */
133
+ public function getCollection($storeId)
134
+ {
135
+ $products = array();
136
+
137
+ $store = Mage::app()->getStore($storeId);
138
+ /* @var $store Mage_Core_Model_Store */
139
+
140
+ if (!$store) {
141
+ return false;
142
+ }
143
+
144
+ $urCondions = array(
145
+ 'e.entity_id=ur.product_id',
146
+ 'ur.category_id IS NULL',
147
+ $this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
148
+ $this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
149
+ );
150
+ $this->_select = $this->_getWriteAdapter()->select()
151
+ ->from(array('e' => $this->getMainTable()), array($this->getIdFieldName()))
152
+ ->join(
153
+ array('w' => $this->getTable('catalog/product_website')),
154
+ 'e.entity_id=w.product_id',
155
+ array()
156
+ )
157
+ ->where('w.website_id=?', $store->getWebsiteId())
158
+ ->joinLeft(
159
+ array('ur' => $this->getTable('core/url_rewrite')),
160
+ join(' AND ', $urCondions),
161
+ array('url' => 'request_path')
162
+ );
163
+
164
+ $this->_addFilter($storeId, 'visibility', Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds(), 'in');
165
+ $this->_addFilter($storeId, 'status', Mage::getSingleton('catalog/product_status')->getVisibleStatusIds(), 'in');
166
+
167
+ $query = $this->_getWriteAdapter()->query($this->_select);
168
+ while ($row = $query->fetch()) {
169
+ $product = $this->_prepareProduct($row);
170
+ $products[$product->getId()] = $product;
171
+ }
172
+
173
+ return $products;
174
+ }
175
+
176
+ /**
177
+ * Prepare product
178
+ *
179
+ * @param array $productRow
180
+ * @return Varien_Object
181
+ */
182
+ protected function _prepareProduct(array $productRow)
183
+ {
184
+ $product = new Varien_Object();
185
+ $product->setId($productRow[$this->getIdFieldName()]);
186
+ $productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
187
+ $product->setUrl($productUrl);
188
+ return $product;
189
+ }
190
+ }
app/code/local/Harapartners/SitemapXml/Model/Resource/Language.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+
14
+ class Harapartners_SitemapXml_Model_Resource_Language extends Mage_Core_Model_Resource_Db_Abstract {
15
+
16
+ protected function _construct() {
17
+ $this->_init('sitemapxml/sitemap_language', 'language_id');
18
+ }
19
+ }
app/code/local/Harapartners/SitemapXml/Model/Resource/Language/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+
14
+ class Harapartners_SitemapXml_Model_Resource_Language_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
15
+ {
16
+
17
+ public function _construct()
18
+ {
19
+ $this->_init('sitemapxml/language');
20
+ }
21
+ }
app/code/local/Harapartners/SitemapXml/Model/Rewrite/Sitemap/Sitemap.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sitemap
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Sitemap model
29
+ *
30
+ * @method Mage_Sitemap_Model_Resource_Sitemap _getResource()
31
+ * @method Mage_Sitemap_Model_Resource_Sitemap getResource()
32
+ * @method string getSitemapType()
33
+ * @method Mage_Sitemap_Model_Sitemap setSitemapType(string $value)
34
+ * @method string getSitemapFilename()
35
+ * @method Mage_Sitemap_Model_Sitemap setSitemapFilename(string $value)
36
+ * @method string getSitemapPath()
37
+ * @method Mage_Sitemap_Model_Sitemap setSitemapPath(string $value)
38
+ * @method string getSitemapTime()
39
+ * @method Mage_Sitemap_Model_Sitemap setSitemapTime(string $value)
40
+ * @method int getStoreId()
41
+ * @method Mage_Sitemap_Model_Sitemap setStoreId(int $value)
42
+ *
43
+ * @category Mage
44
+ * @package Mage_Sitemap
45
+ * @author Magento Core Team <core@magentocommerce.com>
46
+ */
47
+ class Harapartners_Sitemapxml_Model_Rewrite_Sitemap_Sitemap extends Mage_Sitemap_Model_Sitemap
48
+ {
49
+ const LANGUAGE_FILENAME = 'language.xml';
50
+
51
+ protected $_xmlGenLang;
52
+
53
+ /**
54
+ * Generate XML file
55
+ *
56
+ * @return Mage_Sitemap_Model_Sitemap
57
+ */
58
+ public function generateXml()
59
+ {
60
+ if (! $this->_isLanguageEnabled()) {
61
+ return parent::generateXml();
62
+ }
63
+
64
+ $io = new Varien_Io_File();
65
+ $io->setAllowCreateFolders(true);
66
+ $io->open(array(
67
+ 'path' => $this->getPath()
68
+ ));
69
+
70
+ if ($io->fileExists($this->getSitemapFilename()) && ! $io->isWriteable($this->getSitemapFilename())) {
71
+ Mage::throwException(Mage::helper('sitemap')->__('File "%s" cannot be saved. Please, make sure the directory "%s" is writeable by web server.', $this->getSitemapFilename(), $this->getPath()));
72
+ }
73
+
74
+ $io->streamOpen($this->getSitemapFilename());
75
+
76
+ $io->streamWrite('<?xml version="1.0" encoding="UTF-8"?>' . "\n");
77
+ $io->streamWrite('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">');
78
+
79
+ $storeId = $this->getStoreId();
80
+ $date = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
81
+ $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
82
+
83
+ /**
84
+ * Generate categories sitemap
85
+ */
86
+ $changefreq = (string) Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
87
+ $priority = (string) Mage::getStoreConfig('sitemap/category/priority', $storeId);
88
+ $collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId);
89
+ foreach ($collection as $item) {
90
+ $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>', htmlspecialchars($baseUrl . $item->getUrl()), $date, $changefreq, $priority);
91
+ $newXml = $this->_insertLanguageXml($baseUrl, $item, 'category', $xml);
92
+ $io->streamWrite($newXml);
93
+ }
94
+ unset($collection);
95
+
96
+
97
+ /**
98
+ * Generate products sitemap
99
+ */
100
+ $changefreq = (string) Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
101
+ $priority = (string) Mage::getStoreConfig('sitemap/product/priority', $storeId);
102
+ $collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
103
+ $collection = $this->_joinByOtherStoreIds($collection, $this->_getOtherStoreIds($storeId));
104
+ foreach ($collection as $item) {
105
+ $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>', htmlspecialchars($baseUrl . $item->getUrl()), $date, $changefreq, $priority);
106
+ $newXml = $this->_insertLanguageXml($baseUrl, $item, 'product', $xml);
107
+ $io->streamWrite($newXml);
108
+ }
109
+ unset($collection);
110
+
111
+ /**
112
+ * Generate cms pages sitemap
113
+ */
114
+ $changefreq = (string) Mage::getStoreConfig('sitemap/page/changefreq', $storeId);
115
+ $priority = (string) Mage::getStoreConfig('sitemap/page/priority', $storeId);
116
+ $collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
117
+ foreach ($collection as $item) {
118
+ $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>', htmlspecialchars($baseUrl . $item->getUrl()), $date, $changefreq, $priority);
119
+ $io->streamWrite($xml);
120
+ }
121
+ unset($collection);
122
+
123
+ $io->streamWrite('</urlset>');
124
+ $io->streamClose();
125
+
126
+ $this->setSitemapTime(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s'));
127
+ $this->save();
128
+
129
+ return $this;
130
+ }
131
+
132
+ protected function _insertLanguageXml($baseUrl, $item, $itemType, $xml)
133
+ {
134
+ if (! $item->getId() || ! $item->getUrl()) {
135
+ return $xml;
136
+ }
137
+
138
+ $insertXml = $this->_getLanguageXml($baseUrl, $item, $itemType);
139
+
140
+ $count = 0;
141
+ $returnXml = str_replace('</url>', ' ' . $insertXml . ' </url>', $xml, $count);
142
+ $oldKeep = substr($xml, 0, strlen($xml) - 6);
143
+ $returnXml = $oldKeep . ' ' . $insertXml . ' </url>';
144
+ $count = 1;
145
+ if ($count != 1) {
146
+ //error
147
+ return $xml;
148
+ } else {
149
+ return $returnXml;
150
+ }
151
+
152
+ }
153
+
154
+ protected function _getLanguageXml($baseUrl, $item, $itemType)
155
+ {
156
+ return $this->_getXmlLangGen()->getUrlBlock($baseUrl, $item, $itemType, false);
157
+ }
158
+
159
+ /**
160
+ * Enter description here...
161
+ *
162
+ * @return Harapartners_SitemapXml_Model_Source_Xml
163
+ */
164
+ protected function _getXmlLangGen()
165
+ {
166
+ if (! isset($this->_xmlGenLang)) {
167
+ $this->_xmlGenLang = Mage::getModel('sitemapxml/source_xml');
168
+ }
169
+
170
+ return $this->_xmlGenLang;
171
+ }
172
+
173
+ protected function _isLanguageEnabled()
174
+ {
175
+ $siteMapFilename = $this->getSitemapFilename();
176
+ if ($siteMapFilename !== self::LANGUAGE_FILENAME) {
177
+ //return false;
178
+ }
179
+
180
+ return Mage::helper('sitemapxml')->isLanguageEnabled();
181
+ }
182
+
183
+ protected function _getOtherStoreIds($oldStoreId)
184
+ {
185
+ $allStores = Mage::app()->getStores();
186
+ foreach(Mage::getModel('sitemapxml/language')->getCollection() as $site){
187
+ $sites[$site->getStoreViewId()] = true;
188
+ }
189
+
190
+ $collection = Mage::getModel('sitemapxml/language')->getCollection();
191
+ foreach ($allStores as $storeId => $val) {
192
+ if ($storeId != $oldStoreId && isset($sites[$storeId])) {
193
+ $otherStores[] = $storeId;
194
+ }
195
+ }
196
+
197
+ return $otherStores;
198
+ }
199
+
200
+ protected function _joinByOtherStoreIds($currentCollection, $newStoreIds)
201
+ {
202
+ if (empty($newStoreIds)) {
203
+ return $currentCollection;
204
+ }
205
+
206
+ foreach ($currentCollection as $product) {
207
+ $id = $product->getId();
208
+ $ids[$id] = true;
209
+ }
210
+
211
+
212
+ foreach ($newStoreIds as $storeId) {
213
+ $tempCollection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
214
+
215
+ foreach ($tempCollection as $product) {
216
+ $id = $product->getId();
217
+ if (! isset($ids[$id])) {
218
+ $ids[$id] = true;
219
+ $currentCollection[] = $product;
220
+ }
221
+ }
222
+ }
223
+ return $currentCollection;
224
+ }
225
+ }
app/code/local/Harapartners/SitemapXml/Model/Source/Store.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SitemapXml_Model_Source_Store
14
+ {
15
+
16
+ public function getStoreIds()
17
+ {
18
+ $stores = Mage::app()->getStores();
19
+
20
+ $storename = array();
21
+ foreach ($stores as $store) {
22
+ $id = $store->getId();
23
+ $name = $store->getName();
24
+ $storename[$id] = $name;
25
+ }
26
+
27
+ return $storename;
28
+ }
29
+
30
+ protected function _toOptionArray($skipUsed = false)
31
+ {
32
+ $optionArray = array();
33
+ if ($skipUsed) {
34
+ $usedIds = $this->_getUsedIds();
35
+ } else {
36
+ $usedIds = array();
37
+ }
38
+
39
+ foreach ($this->getStoreIds() as $id => $name) {
40
+ if (isset($usedIds[$id]) && $skipUsed) {
41
+ continue;
42
+ }
43
+
44
+ $optionArray[] = array(
45
+ 'value' => $id ,
46
+ 'label' => $name
47
+ );
48
+ }
49
+ return $optionArray;
50
+ }
51
+
52
+ public function toOptionArray()
53
+ {
54
+ return $this->_toOptionArray(true);
55
+ }
56
+
57
+ protected function _getUsedIds(){
58
+ $collection = Mage::getModel('sitemapxml/language')->getCollection();
59
+
60
+ $usedId = array();
61
+ foreach($collection as $language){
62
+ $id = $language->getStoreViewId();
63
+ $usedId[$id] =true;
64
+ }
65
+
66
+ return $usedId;
67
+ }
68
+ }
app/code/local/Harapartners/SitemapXml/Model/Source/Xml.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SitemapXml_Model_Source_Xml
14
+ {
15
+ const XML_PATH_VALIDATE_URL = 'sitemap/language/validate_url';
16
+
17
+ protected $_links;
18
+ protected $_validator;
19
+
20
+ public function getLinks()
21
+ {
22
+ if (empty($this->_links)) {
23
+ $collection = Mage::getModel('sitemapxml/language')->getCollection();
24
+
25
+ $links[] = $this->_getXDefualtLink();
26
+ foreach ($collection as $language) {
27
+ $storeId = $language->getStoreViewId();
28
+ $langCode = $language->getLanguageCode();
29
+ $href = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, false);
30
+ $links[] = array(
31
+ 'lang_code' => $langCode ,
32
+ 'href' => $href ,
33
+ 'store_id' => $storeId
34
+ );
35
+ }
36
+
37
+ $this->_links = $links;
38
+ }
39
+
40
+ return $this->_links;
41
+ }
42
+
43
+ protected function _getXDefualtLink()
44
+ {
45
+ $xUrl = Mage::getStoreConfig('sitemap/language/x_default_url');
46
+ if (empty($xUrl)) {
47
+ $xUrl = Mage::getBaseUrl();
48
+ }
49
+
50
+ return array(
51
+ 'lang_code' => 'x-default' ,
52
+ 'href' => $xUrl
53
+ );
54
+ }
55
+
56
+ protected function _getValidator()
57
+ {
58
+ if (! isset($validator)) {
59
+ $this->_validator = Mage::getModel('sitemapxml/controller_validator');
60
+ }
61
+
62
+ return $this->_validator;
63
+ }
64
+
65
+ public function getUrlBlock($baseUrl, $item, $itemType, $prettyPrint = false)
66
+ {
67
+ $conditionalLineEnding = '';
68
+ $conditionalTab = '';
69
+ if ($prettyPrint) {
70
+ $conditionalLineEnding = PHP_EOL;
71
+ $conditionalTab = "\t";
72
+ }
73
+
74
+ $links = $this->getLinks();
75
+
76
+ $string = '';
77
+ //$string = '<url>' . $conditionalLineEnding;
78
+ //$string = "$conditionalTab <loc>{$baseUrl}</loc>" . $conditionalLineEnding;
79
+ $suffixPaths = $this->_getSuffixPathsById($itemType, $item->getId());
80
+ foreach ($links as $link) {
81
+ $suffixpath = isset($suffixPaths[$link['store_id']]) ? $suffixPaths[$link['store_id']] : $item->getUrl();
82
+ $readyLink = $link['href'] . $suffixpath;
83
+ if (! $this->_isLinkValid($readyLink)) {
84
+ continue;
85
+ }
86
+
87
+ $string .= $conditionalTab . "<xhtml:link rel=\"alternate\" hreflang=\"{$link['lang_code']}\" href=\"{$readyLink}\" />" . $conditionalLineEnding;
88
+ }
89
+
90
+ return $string;
91
+ }
92
+
93
+ protected function _getSuffixPathsById($type, $id)
94
+ {
95
+ $collection = Mage::getModel('core/url_rewrite')->getCollection();
96
+ switch ($type) {
97
+ case 'product':
98
+ $collection->filterAllByProductId($id);
99
+ break;
100
+ case 'category':
101
+ $this->_addCollectionFilterToCollection($collection, $id);
102
+ break;
103
+ default:
104
+ return array();
105
+ }
106
+
107
+ $paths = array();
108
+ foreach ($collection as $urlRewrite) {
109
+ // TODO only Newest ??
110
+ $storeId = $urlRewrite->getStoreId();
111
+ $path = $urlRewrite->getRequestPath();
112
+ $paths[$storeId] = $path;
113
+ }
114
+
115
+ return $paths;
116
+ }
117
+
118
+ protected function _addCollectionFilterToCollection($collection, $id)
119
+ {
120
+ $collection->getSelect()->where('id_path LIKE ?', "category/{$id}");
121
+ return $this;
122
+ }
123
+
124
+ protected function _isLinkValid($link)
125
+ {
126
+ if (! Mage::getStoreConfig(self::XML_PATH_VALIDATE_URL)) {
127
+ // Are we validating URLs?
128
+ return true;
129
+ }
130
+
131
+ $url = $link;
132
+ $ch = curl_init($url);
133
+ curl_setopt($ch, CURLOPT_NOBODY, true);
134
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
135
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
136
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
137
+
138
+ curl_exec($ch);
139
+ $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
140
+ curl_close($ch);
141
+
142
+ if (200 == $retcode) {
143
+ // All's well
144
+ return true;
145
+ } else {
146
+ // not so much
147
+ return false;
148
+ }
149
+
150
+ return true;
151
+ }
152
+ }
app/code/local/Harapartners/SitemapXml/controllers/Adminhtml/LanguageController.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_Sitemapxml_Adminhtml_LanguageController extends Mage_Adminhtml_Controller_Action {
14
+
15
+ /**
16
+ * View form action
17
+ */
18
+ public function indexAction() {
19
+ $this->loadLayout ();
20
+ $this->_setActiveMenu ( 'sitemapxml/language' );
21
+ //$this->_addBreadcrumb ( Mage::helper ( 'webservice' )->__ ( 'Product1' ), Mage::helper ( 'webservice' )->__ ( 'Form' ) );
22
+ $this->_addContent ( $this->getLayout ()->createBlock ( 'sitemapxml/adminhtml_language_index' ) );
23
+ $this->renderLayout ();
24
+ }
25
+
26
+ public function editAction() {
27
+ $id = $this->getRequest ()->getParam ( 'id' );
28
+ $model = Mage::getModel ( 'sitemapxml/language' )->load ( $id );
29
+
30
+ if ($model->getId () || $id == 0) {
31
+ $data = Mage::getSingleton ( 'adminhtml/session' )->getData ( 'sitemapxml_language_data' );
32
+ if (! empty ( $data )) {
33
+ $model->setData ( $data );
34
+ }
35
+
36
+ Mage::register ( 'sitemapxml_language_data', $model );
37
+
38
+ $this->loadLayout ()->_setActiveMenu ( 'sitemapxml/language' );
39
+
40
+ //$this->_addBreadcrumb ( Mage::helper ( 'sitemapxml' )->__ ( 'Manage Buy X Rules' ), Mage::helper ( 'adminhtml' )->__ ( 'Manage Buy X Rules' ) );
41
+ //$this->_addBreadcrumb ( Mage::helper ( 'sitemapxml' )->__ ( 'Buy X Rule Configuration' ), Mage::helper ( 'adminhtml' )->__ ( 'Buy X Rule Configuration' ) );
42
+
43
+ $this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true );
44
+
45
+ $this->_addContent ( $this->getLayout ()->createBlock ( 'sitemapxml/adminhtml_language_edit' ) );
46
+
47
+ $this->renderLayout ();
48
+ } else {
49
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'sitemapxml' )->__ ( 'Language Map does not exist' ) );
50
+ $this->_redirect ( '*/*/' );
51
+ }
52
+ }
53
+
54
+ public function newAction(){
55
+ return $this->editAction();
56
+ }
57
+
58
+ public function saveAction() {
59
+ if ($data = $this->getRequest ()->getPost ()) {
60
+ $model = Mage::getModel ( 'sitemapxml/language' );
61
+ $model->setData ( $data )->setId ( $this->getRequest ()->getParam ( 'id' ) );
62
+
63
+ try {
64
+ $model->save ();
65
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'sitemapxml' )->__ ( 'Language Map Saved' ) );
66
+ Mage::getSingleton ( 'adminhtml/session' )->setData ( false );
67
+
68
+ if ($this->getRequest ()->getParam ( 'back' )) {
69
+ $this->_redirect ( '*/*/edit', array ('id' => $model->getId () ) );
70
+ return;
71
+ }
72
+ $this->_redirect ( '*/*/' );
73
+ return;
74
+ } catch ( Exception $e ) {
75
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
76
+ Mage::getSingleton ( 'adminhtml/session' )->setData ('sitemapxml_language_data', $data );
77
+ $this->_redirect ( '*/*/edit', array ('id' => $this->getRequest ()->getParam ( 'id' ) ) );
78
+ return;
79
+ }
80
+ }
81
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'sitemapxml' )->__ ( 'Unable to find Language Map to Save' ) );
82
+ $this->_redirect ( '*/*/' );
83
+ }
84
+
85
+ public function deleteAction() {
86
+ if ($id = $this->getRequest ()->getParam ( 'id' )) {
87
+ $model = Mage::getModel ( 'sitemapxml/language' );
88
+ $model->setId ( $id );
89
+
90
+ try {
91
+ $model->delete ();
92
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'sitemapxml' )->__ ( 'Language Map Deleted' ) );
93
+ Mage::getSingleton ( 'adminhtml/session' )->setData ( false );
94
+
95
+ if ($this->getRequest ()->getParam ( 'back' )) {
96
+ $this->_redirect ( '*/*/');
97
+ return;
98
+ }
99
+ $this->_redirect ( '*/*/' );
100
+ return;
101
+ } catch ( Exception $e ) {
102
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
103
+ Mage::getSingleton ( 'adminhtml/session' )->setData ('sitemapxml_language_data', $data );
104
+ $this->_redirect ( '*/*/edit', array ('id' => $this->getRequest ()->getParam ( 'id' ) ) );
105
+ return;
106
+ }
107
+ }
108
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'sitemapxml' )->__ ( 'Unable to find Language Map to Delete' ) );
109
+ $this->_redirect ( '*/*/' );
110
+ }
111
+ }
app/code/local/Harapartners/SitemapXml/etc/adminhtml.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ * @author Steven Hoffman <s.hoffman@harapartners.com>
13
+ * @copyright Copyright (c) 2013 Harapartners Inc.
14
+ *
15
+ -->
16
+ <!-- app/code/local/Harapartners/Edi/etc/adminhtml.xml -->
17
+
18
+ <config>
19
+ <menu>
20
+ <catalog>
21
+ <children>
22
+ <sitemap_language translate="title" module="sitemapxml">
23
+ <title>Google Sitemap Store - Languages</title>
24
+ <sort_order>200</sort_order>
25
+ <action>sitemapxml_adminhtml/language</action>
26
+ </sitemap_language>
27
+ </children>
28
+ </catalog>
29
+ </menu>
30
+ <acl>
31
+ <resources>
32
+ <admin>
33
+ <children>
34
+ <catalog>
35
+ <children>
36
+ <sitemap_language translate="title" module="sitemapxml">
37
+ <title>Language Map</title>
38
+ </sitemap_language>
39
+ </children>
40
+ </catalog>
41
+ </children>
42
+ </admin>
43
+ </resources>
44
+ </acl>
45
+ </config>
app/code/local/Harapartners/SitemapXml/etc/config.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Harapartners_SitemapXml>
16
+ <version>1.0.0</version>
17
+ </Harapartners_SitemapXml>
18
+ </modules>
19
+ <global>
20
+ <blocks>
21
+ <sitemapxml>
22
+ <class>Harapartners_SitemapXml_Block</class>
23
+ </sitemapxml>
24
+ </blocks>
25
+ <models>
26
+ <sitemapxml>
27
+ <class>Harapartners_SitemapXml_Model</class>
28
+ <resourceModel>sitemapxml_resource</resourceModel>
29
+ </sitemapxml>
30
+ <sitemap>
31
+ <rewrite>
32
+ <sitemap>Harapartners_SitemapXml_Model_Rewrite_Sitemap_Sitemap</sitemap>
33
+ </rewrite>
34
+ </sitemap>
35
+ <sitemapxml_resource>
36
+ <class>Harapartners_SitemapXml_Model_Resource</class>
37
+ <entities>
38
+ <sitemap_language>
39
+ <table>harapartners_sitemap_language</table>
40
+ </sitemap_language>
41
+ </entities>
42
+ </sitemapxml_resource>
43
+ </models>
44
+ <resources>
45
+ <sitemapxml_setup>
46
+ <setup>
47
+ <module>Harapartners_SitemapXml</module>
48
+ </setup>
49
+ <connection>
50
+ <use>core_setup</use>
51
+ </connection>
52
+ </sitemapxml_setup>
53
+ </resources>
54
+ <helpers>
55
+ <sitemapxml>
56
+ <class>Harapartners_SitemapXml_Helper</class>
57
+ </sitemapxml>
58
+ <adminhtml>
59
+ <rewrite>
60
+ <catalog>Harapartners_SitemapXml_Helper_Rewrite_Adminhtml_Catalog</catalog>
61
+ </rewrite>
62
+ </adminhtml>
63
+ </helpers>
64
+ </global>
65
+ <admin>
66
+ <routers>
67
+ <sitemapxml_adminhtml>
68
+ <use>admin</use>
69
+ <args>
70
+ <module>Harapartners_SitemapXml_Adminhtml</module>
71
+ <frontName>sitemapxml_adminhtml</frontName>
72
+ </args>
73
+ </sitemapxml_adminhtml>
74
+ </routers>
75
+ </admin>
76
+ <!--
77
+ <crontab>
78
+ <jobs>
79
+ <edi_sync>
80
+ <schedule>
81
+ <cron_expr>0,30 * * * *</cron_expr>
82
+ </schedule>
83
+ <run>
84
+ <model>edi/observer::createSendRecieveSyncEdi</model>
85
+ </run>
86
+ </edi_sync>
87
+ </jobs>
88
+ </crontab>
89
+ -->
90
+ </config>
app/code/local/Harapartners/SitemapXml/etc/system.xml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ * @author Steven Hoffman <s.hoffman@harapartners.com>
13
+ * @copyright Copyright (c) 2013 Harapartners Inc.
14
+ *
15
+ -->
16
+ <!-- app/code/local/Harapartners/Edi/etc/system.xml -->
17
+
18
+ <config>
19
+ <sections>
20
+ <sitemap>
21
+ <groups>
22
+ <language>
23
+ <label>Langauge Settings</label>
24
+ <sort_order>40</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ <fields>
29
+ <is_enabled translate="label">
30
+ <label>Enable this Addon</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <sort_order>5</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ </is_enabled>
38
+ <x_default_url translate="label">
39
+ <label>X-Default Base Url</label>
40
+ <comment>Leave Blank to use Site Default </comment>
41
+ <frontend_type>text</frontend_type>
42
+ <validate>validate-url</validate>
43
+ <sort_order>10</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </x_default_url>
48
+ <validate_url translate="label">
49
+ <label>Ping URL to Validate Link</label>
50
+ <comment>(200 is a valid responce code)</comment>
51
+ <frontend_type>select</frontend_type>
52
+ <source_model>adminhtml/system_config_source_yesno</source_model>
53
+ <sort_order>15</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>0</show_in_store>
57
+ </validate_url>
58
+ </fields>
59
+ </language>
60
+ </groups>
61
+ </sitemap>
62
+ </sections>
63
+ </config>
app/code/local/Harapartners/SitemapXml/sql/sitemapxml_setup/install-1.0.0.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+ $table = $installer->getConnection()
16
+ ->newTable($installer->getTable('sitemapxml/sitemap_language'))
17
+ ->addColumn('language_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
18
+ 'identity' => true,
19
+ 'unsigned' => true,
20
+ 'nullable' => false,
21
+ 'primary' => true,
22
+ ), 'Auto Increment Language Map ID')
23
+ ->addColumn('store_view_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
24
+ 'unsigned' => true,
25
+ 'nullable' => false,
26
+ ), 'Record Map Status')
27
+ ->addColumn('language_code', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
28
+ 'nullable' => false,
29
+ ), 'Language Code')
30
+ ->addIndex(
31
+ $installer->getIdxName('sitemapxml/sitemap_language', array('store_view_id')),
32
+ array('store_view_id'),
33
+ array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
34
+ )
35
+ ->setComment('Sitemap Xml Language Map');
36
+ $installer->getConnection()->createTable( $table );
37
+ $installer->endSetup();
app/etc/modules/Harapartners_Sitemapxml.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Harapartners_SitemapXml>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Harapartners_SitemapXml>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MultiLanguage_Sitemap</name>
4
+ <version>1.0.3</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.elieandmai.com/eula">Elie and Mai End User License Agreement</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Multi-Language Sitemap Optimization Magento module automatically generates a multi-language sitemap supported by Google.</summary>
10
+ <description>This extension will allow for you to Search Engine optimize your Magento store for multiple languages. This extension give you the ability to create a &#x201C;language sitemap&#x201D; which you can submit in Google Webmaster tools. This language sitemap tells Google which version page to display in the counties you specify. For example, you can indicate that you want us.example.com to rank for US visitors or fr.example.com to rank in France.</description>
11
+ <notes>First Stable Version for General Use of the Multi-Language Optimization (hreflang).&#xD;
12
+ &#xD;
13
+ This version properly configured automatically generates a multi-language sitemap supported by Google.</notes>
14
+ <authors><author><name>Elie Orgel</name><user>elieandmai</user><email>magento@elieandmai.com</email></author></authors>
15
+ <date>2014-05-16</date>
16
+ <time>19:38:08</time>
17
+ <contents><target name="magelocal"><dir name="Harapartners"><dir name="SitemapXml"><dir name="Block"><dir name="Adminhtml"><dir name="Language"><dir name="Edit"><file name="Form.php" hash="cc7626b3ce229ab2ecd53367b279c64a"/></dir><file name="Edit.php" hash="4e3c1b8c75082b1021a79765a19f095f"/><dir name="Index"><file name="Grid.php" hash="eaefaf1259dd7dbf7040b2e00bc4ae05"/></dir><file name="Index.php" hash="76dec39b4af1821624c0f0460d7a793b"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="3247339dd38b724fe10783ebb65f12dd"/><dir name="Rewrite"><dir name="Adminhtml"><file name="Catalog.php" hash="4014d9de20574f2163f793c7287037f0"/></dir></dir></dir><dir name="Model"><file name="Language.php" hash="244d1d82a6365eb33e8bd475f6cc3793"/><dir name="Resource"><dir name="Catalog"><file name="Product.php" hash="c6bc72c42bd106756893a524db7bc6b9"/></dir><dir name="Language"><file name="Collection.php" hash="dc064cf886b3d7992d34af27da069b5f"/></dir><file name="Language.php" hash="99e8bebe005f841cda6e2330b9c8f6e2"/></dir><dir name="Rewrite"><dir name="Sitemap"><file name="Sitemap.php" hash="ee89c4cd240fcd2946d3928134ea35d9"/></dir></dir><dir name="Source"><file name="Store.php" hash="3f0ea63fde41b3b0d55ee888fcc8ef85"/><file name="Xml.php" hash="f60b6e6bf1f570685ebbc893357a6685"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LanguageController.php" hash="090aa123a35a9c6fa06259555a6566e1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="d9ae504e4afc73941cbba59116c6dcfe"/><file name="config.xml" hash="13a6a58523ba01841c010f3b1db8b3bf"/><file name="system.xml" hash="affc7706807dd4eae6019ab165937a82"/></dir><dir name="sql"><dir name="sitemapxml_setup"><file name="install-1.0.0.php" hash="9b84cb415328cc6283db06cf9462e297"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Harapartners_Sitemapxml.xml" hash="38018c4b411931ea63efd16eb4141f1e"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>