Version Notes
Added support to older Magento versions, including Magento 1.5.x.x.
Download this release
Release Info
Developer | Activo Extensions |
Extension | Activo_Xmlsitemap |
Version | 0.5.0 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.5.0
- app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Catalog/Category.php +72 -0
- app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Catalog/Product.php +69 -0
- app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Cms/Page.php +51 -0
- app/code/community/Activo/Xmlsitemap/etc/config.xml +12 -0
- app/etc/modules/Activo_Xmlsitemap.xml +0 -10
- package.xml +5 -5
app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Catalog/Category.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Activo_Xmlsitemap_Model_Sitemap_Mysql4_Catalog_Category extends Mage_Sitemap_Model_Mysql4_Catalog_Category
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get category collection array
|
6 |
+
*
|
7 |
+
* @param unknown_type $storeId
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getCollection($storeId)
|
11 |
+
{
|
12 |
+
$categories = array();
|
13 |
+
|
14 |
+
$store = Mage::app()->getStore($storeId);
|
15 |
+
/* @var $store Mage_Core_Model_Store */
|
16 |
+
|
17 |
+
if (!$store) {
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->_select = $this->_getWriteAdapter()->select()
|
22 |
+
->from($this->getMainTable())
|
23 |
+
->where($this->getIdFieldName() . '=?', $store->getRootCategoryId());
|
24 |
+
$categoryRow = $this->_getWriteAdapter()->fetchRow($this->_select);
|
25 |
+
|
26 |
+
if (!$categoryRow) {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
$urConditions = array(
|
31 |
+
'e.entity_id=ur.category_id',
|
32 |
+
$this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
|
33 |
+
'ur.product_id IS NULL',
|
34 |
+
$this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
|
35 |
+
);
|
36 |
+
$this->_select = $this->_getWriteAdapter()->select()
|
37 |
+
->from(array('e' => $this->getMainTable()), array($this->getIdFieldName(), 'created_at', 'updated_at'))
|
38 |
+
->joinLeft(
|
39 |
+
array('ur' => $this->getTable('core/url_rewrite')),
|
40 |
+
join(' AND ', $urConditions),
|
41 |
+
array('url'=>'request_path')
|
42 |
+
)
|
43 |
+
->where('e.path LIKE ?', $categoryRow['path'] . '/%');
|
44 |
+
|
45 |
+
$this->_addFilter($storeId, 'is_active', 1);
|
46 |
+
|
47 |
+
$query = $this->_getWriteAdapter()->query($this->_select);
|
48 |
+
while ($row = $query->fetch()) {
|
49 |
+
$category = $this->_prepareCategory($row);
|
50 |
+
$categories[$category->getId()] = $category;
|
51 |
+
}
|
52 |
+
|
53 |
+
return $categories;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Prepare category
|
58 |
+
*
|
59 |
+
* @param array $categoryRow
|
60 |
+
* @return Varien_Object
|
61 |
+
*/
|
62 |
+
protected function _prepareCategory(array $categoryRow)
|
63 |
+
{
|
64 |
+
$category = new Varien_Object();
|
65 |
+
$category->setId($categoryRow[$this->getIdFieldName()]);
|
66 |
+
$categoryUrl = !empty($categoryRow['url']) ? $categoryRow['url'] : 'catalog/category/view/id/' . $category->getId();
|
67 |
+
$category->setUrl($categoryUrl);
|
68 |
+
$category->setCreatedAt($categoryRow['created_at']);
|
69 |
+
$category->setUpdatedAt($categoryRow['updated_at']);
|
70 |
+
return $category;
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Catalog/Product.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Activo_Xmlsitemap_Model_Sitemap_Mysql4_Catalog_Product extends Mage_Sitemap_Model_Mysql4_Catalog_Product
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get category collection array
|
6 |
+
*
|
7 |
+
* @param unknown_type $storeId
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function getCollection($storeId)
|
11 |
+
{
|
12 |
+
$products = array();
|
13 |
+
|
14 |
+
$store = Mage::app()->getStore($storeId);
|
15 |
+
/* @var $store Mage_Core_Model_Store */
|
16 |
+
|
17 |
+
if (!$store) {
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
$urCondions = array(
|
22 |
+
'e.entity_id=ur.product_id',
|
23 |
+
'ur.category_id IS NULL',
|
24 |
+
$this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
|
25 |
+
$this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
|
26 |
+
);
|
27 |
+
$this->_select = $this->_getWriteAdapter()->select()
|
28 |
+
->from(array('e' => $this->getMainTable()), array($this->getIdFieldName(), 'created_at', 'updated_at'))
|
29 |
+
->join(
|
30 |
+
array('w' => $this->getTable('catalog/product_website')),
|
31 |
+
'e.entity_id=w.product_id',
|
32 |
+
array()
|
33 |
+
)
|
34 |
+
->where('w.website_id=?', $store->getWebsiteId())
|
35 |
+
->joinLeft(
|
36 |
+
array('ur' => $this->getTable('core/url_rewrite')),
|
37 |
+
join(' AND ', $urCondions),
|
38 |
+
array('url' => 'request_path')
|
39 |
+
);
|
40 |
+
|
41 |
+
$this->_addFilter($storeId, 'visibility', Mage::getSingleton('catalog/product_visibility')->getVisibleInSiteIds(), 'in');
|
42 |
+
$this->_addFilter($storeId, 'status', Mage::getSingleton('catalog/product_status')->getVisibleStatusIds(), 'in');
|
43 |
+
|
44 |
+
$query = $this->_getWriteAdapter()->query($this->_select);
|
45 |
+
while ($row = $query->fetch()) {
|
46 |
+
$product = $this->_prepareProduct($row);
|
47 |
+
$products[$product->getId()] = $product;
|
48 |
+
}
|
49 |
+
|
50 |
+
return $products;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Prepare product
|
55 |
+
*
|
56 |
+
* @param array $productRow
|
57 |
+
* @return Varien_Object
|
58 |
+
*/
|
59 |
+
protected function _prepareProduct(array $productRow)
|
60 |
+
{
|
61 |
+
$product = new Varien_Object();
|
62 |
+
$product->setId($productRow[$this->getIdFieldName()]);
|
63 |
+
$productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
|
64 |
+
$product->setUrl($productUrl);
|
65 |
+
$product->setCreatedAt($productRow['created_at']);
|
66 |
+
$product->setUpdatedAt($productRow['updated_at']);
|
67 |
+
return $product;
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Activo/Xmlsitemap/Model/Sitemap/Mysql4/Cms/Page.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Activo_Xmlsitemap_Model_Sitemap_Mysql4_Cms_Page extends Mage_Sitemap_Model_Mysql4_Cms_Page
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Retrieve cms page collection array
|
7 |
+
*
|
8 |
+
* @param unknown_type $storeId
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function getCollection($storeId)
|
12 |
+
{
|
13 |
+
$pages = array();
|
14 |
+
|
15 |
+
$select = $this->_getWriteAdapter()->select()
|
16 |
+
->from(array('main_table' => $this->getMainTable()), array($this->getIdFieldName(), 'identifier AS url', 'creation_time', 'update_time'))
|
17 |
+
->join(
|
18 |
+
array('store_table' => $this->getTable('cms/page_store')),
|
19 |
+
'main_table.page_id=store_table.page_id',
|
20 |
+
array()
|
21 |
+
)
|
22 |
+
->where('main_table.is_active=1')
|
23 |
+
->where('store_table.store_id IN(?)', array(0, $storeId));
|
24 |
+
$query = $this->_getWriteAdapter()->query($select);
|
25 |
+
while ($row = $query->fetch()) {
|
26 |
+
if ($row['url'] == Mage_Cms_Model_Page::NOROUTE_PAGE_ID) {
|
27 |
+
continue;
|
28 |
+
}
|
29 |
+
$page = $this->_prepareObject($row);
|
30 |
+
$pages[$page->getId()] = $page;
|
31 |
+
}
|
32 |
+
|
33 |
+
return $pages;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Prepare page object
|
38 |
+
*
|
39 |
+
* @param array $data
|
40 |
+
* @return Varien_Object
|
41 |
+
*/
|
42 |
+
protected function _prepareObject(array $data)
|
43 |
+
{
|
44 |
+
$object = new Varien_Object();
|
45 |
+
$object->setId($data[$this->getIdFieldName()]);
|
46 |
+
$object->setUrl($data['url']);
|
47 |
+
$object->setCreatedAt($data['creation_time']);
|
48 |
+
$object->setUpdatedAt($data['update_time']);
|
49 |
+
return $object;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Activo/Xmlsitemap/etc/config.xml
CHANGED
@@ -32,6 +32,18 @@
|
|
32 |
<cms_page>Activo_Xmlsitemap_Model_Sitemap_Resource_Cms_Page</cms_page>
|
33 |
</rewrite>
|
34 |
</sitemap_resource>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
</models>
|
36 |
</global>
|
37 |
</config>
|
32 |
<cms_page>Activo_Xmlsitemap_Model_Sitemap_Resource_Cms_Page</cms_page>
|
33 |
</rewrite>
|
34 |
</sitemap_resource>
|
35 |
+
|
36 |
+
<sitemap_mysql4>
|
37 |
+
<rewrite>
|
38 |
+
<catalog_product>Activo_Xmlsitemap_Model_Sitemap_Mysql4_Catalog_Product</catalog_product>
|
39 |
+
</rewrite>
|
40 |
+
<rewrite>
|
41 |
+
<catalog_category>Activo_Xmlsitemap_Model_Sitemap_Mysql4_Catalog_Category</catalog_category>
|
42 |
+
</rewrite>
|
43 |
+
<rewrite>
|
44 |
+
<cms_page>Activo_Xmlsitemap_Model_Sitemap_Mysql4_Cms_Page</cms_page>
|
45 |
+
</rewrite>
|
46 |
+
</sitemap_mysql4>
|
47 |
</models>
|
48 |
</global>
|
49 |
</config>
|
app/etc/modules/Activo_Xmlsitemap.xml
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Activo_Xmlsitemap>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>community</codePool>
|
7 |
-
<version>0.1.0</version>
|
8 |
-
</Activo_Xmlsitemap>
|
9 |
-
</modules>
|
10 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Activo_Xmlsitemap</name>
|
4 |
-
<version>0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://extensions.activo.com/license_professional">Commercial</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Updates core Google Sitemap XML generator to use the correct <lastmod> dates. This makes the whole XML Sitemap more usable by search engines.</summary>
|
10 |
<description>Updates core Google Sitemap XML generator to use the correct <lastmod> dates. This makes the whole XML Sitemap more usable by search engines.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>Activo Extensions</name><user>activo</user><email>extensions@activo.com</email></author></authors>
|
13 |
-
<date>2013-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Activo"><dir name="Xmlsitemap"><dir><dir name="Helper"><file name="Data.php" hash="7e9a738bbd9ee44ae6b4231b9f625a41"/></dir><dir name="Model"><dir name="Sitemap"><dir name="Resource"><dir name="Catalog"><file name="Category.php" hash="41b7efe21c8a8be7a3b08218a49d7a79"/><file name="Product.php" hash="9da077cb52bc186c11076b9464958b94"/></dir><dir name="Cms"><file name="Page.php" hash="333c87e0ba89c95e18ac90c931371c71"/></dir></dir><file name="Sitemap.php" hash="0a2f094cbe15056326ef530d695acec6"/></dir></dir><dir name="etc"><file name="config.xml" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Activo_Xmlsitemap</name>
|
4 |
+
<version>0.5.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://extensions.activo.com/license_professional">Commercial</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Updates core Google Sitemap XML generator to use the correct <lastmod> dates. This makes the whole XML Sitemap more usable by search engines.</summary>
|
10 |
<description>Updates core Google Sitemap XML generator to use the correct <lastmod> dates. This makes the whole XML Sitemap more usable by search engines.</description>
|
11 |
+
<notes>Added support to older Magento versions, including Magento 1.5.x.x.</notes>
|
12 |
<authors><author><name>Activo Extensions</name><user>activo</user><email>extensions@activo.com</email></author></authors>
|
13 |
+
<date>2013-03-27</date>
|
14 |
+
<time>18:56:07</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Activo"><dir name="Xmlsitemap"><dir><dir name="Helper"><file name="Data.php" hash="7e9a738bbd9ee44ae6b4231b9f625a41"/></dir><dir name="Model"><dir name="Sitemap"><dir name="Mysql4"><dir name="Catalog"><file name="Category.php" hash="ff51e0f3c73ad3f49d7f2782ee87d8ef"/><file name="Product.php" hash="6f733786f8bdb588abf2bc458ed16f17"/></dir><dir name="Cms"><file name="Page.php" hash="ff7d48656992bbf15d170ce90cc32629"/></dir></dir><dir name="Resource"><dir name="Catalog"><file name="Category.php" hash="41b7efe21c8a8be7a3b08218a49d7a79"/><file name="Product.php" hash="9da077cb52bc186c11076b9464958b94"/></dir><dir name="Cms"><file name="Page.php" hash="333c87e0ba89c95e18ac90c931371c71"/></dir></dir><file name="Sitemap.php" hash="0a2f094cbe15056326ef530d695acec6"/></dir></dir><dir name="etc"><file name="config.xml" hash="84bf835aad9e9f98ca87c00dcb1aed35"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Activo_Xmlsitemap.xml" hash=""/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
|
18 |
</package>
|