activo_categoryurlseo - Version 1.0.4.1

Version Notes

Flattens the SEO structure of your entire catalog: fixed double slash bug in certain cases.

Download this release

Release Info

Developer Activo Extensions
Extension activo_categoryurlseo
Version 1.0.4.1
Comparing to
See all releases


Code changes from version 1.0.4 to 1.0.4.1

app/code/community/Activo/Categoryurlseo/Helper/Category.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Activo_Categoryurlseo_Helper_Category extends Mage_Catalog_Helper_Category
4
+ {
5
+ /**
6
+ * Retrieve clear url for category as parrent
7
+ *
8
+ * @param string $url
9
+ * @param bool $slash
10
+ * @param int $storeId
11
+ *
12
+ * @return string
13
+ */
14
+ public function getCategoryUrlPath($urlPath, $slash = false, $storeId = null)
15
+ {
16
+ if (Mage::getStoreConfig('activo_categoryurlseo/global/enabled')==0)
17
+ {
18
+ return parent::getCategoryUrlPath($urlPath, $slash, $storeId);
19
+ }
20
+ else
21
+ {
22
+ return Mage::getStoreConfig('activo_categoryurlseo/global/toplevel');
23
+ }
24
+ }
25
+ }
app/code/community/Activo/Categoryurlseo/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Activo OpenSource
4
+ *
5
+ * LICENSE
6
+ *
7
+ * This source file is subject to the new BSD license that is bundled
8
+ * with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://store.delorumcommerce.com/license/new-bsd
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@tinybrick.com so we can send you a copy immediately.
14
+ *
15
+ * @category Activo
16
+ * @package Activo_BulkImages
17
+ * @copyright Copyright (c) 2011 Activo Inc. (http://www.activo.com)
18
+ * @license OSL 3.0
19
+ */
20
+
21
+ class Activo_Categoryurlseo_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+ }
app/code/community/Activo/Categoryurlseo/Model/Url.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Activo_Categoryurlseo_Model_Url extends Mage_Catalog_Model_Url
3
+ {
4
+ /**
5
+ * Get unique product request path
6
+ *
7
+ * @param Varien_Object $product
8
+ * @param Varien_Object $category
9
+ * @return string
10
+ */
11
+ public function getProductRequestPath($product, $category)
12
+ {
13
+ if (Mage::getStoreConfig('activo_categoryurlseo/global/enabled')==0)
14
+ {
15
+ return parent::getProductRequestPath($product, $category);
16
+ }
17
+ else
18
+ {
19
+ if ($product->getUrlKey() == '') {
20
+ $urlKey = $this->getProductModel()->formatUrlKey($product->getName());
21
+ } else {
22
+ $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
23
+ }
24
+ $storeId = $category->getStoreId();
25
+ $suffix = $this->getProductUrlSuffix($storeId);
26
+ $idPath = $this->generatePath('id', $product, $category);
27
+ /**
28
+ * Prepare product base request path
29
+ */
30
+ if ($category->getLevel() > 1) {
31
+ // To ensure, that category has path either from attribute or generated now
32
+ $this->_addCategoryUrlPath($category);
33
+ $categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(),
34
+ false, $storeId);
35
+ if ($categoryUrl == "")
36
+ {
37
+ $requestPath = $urlKey;
38
+ }
39
+ else
40
+ {
41
+ $requestPath = $categoryUrl . '/' . $urlKey;
42
+ }
43
+ $requestPath = str_ireplace('//', '/', $requestPath);
44
+ } else {
45
+ $requestPath = $urlKey;
46
+ }
47
+
48
+ if (strlen($requestPath) > self::MAX_REQUEST_PATH_LENGTH + self::ALLOWED_REQUEST_PATH_OVERFLOW) {
49
+ $requestPath = substr($requestPath, 0, self::MAX_REQUEST_PATH_LENGTH);
50
+ }
51
+
52
+ $this->_rewrite = null;
53
+ /**
54
+ * Check $requestPath should be unique
55
+ */
56
+ if (isset($this->_rewrites[$idPath])) {
57
+ $this->_rewrite = $this->_rewrites[$idPath];
58
+ $existingRequestPath = $this->_rewrites[$idPath]->getRequestPath();
59
+ $existingRequestPath = str_replace($suffix, '', $existingRequestPath);
60
+
61
+ if ($existingRequestPath == $requestPath) {
62
+ return $requestPath.$suffix;
63
+ }
64
+ /**
65
+ * Check if existing request past can be used
66
+ */
67
+ if ($product->getUrlKey() == '' && !empty($requestPath)
68
+ && strpos($existingRequestPath, $requestPath) !== false
69
+ ) {
70
+ $existingRequestPath = str_replace($requestPath, '', $existingRequestPath);
71
+ if (preg_match('#^-([0-9]+)$#i', $existingRequestPath)) {
72
+ return $this->_rewrites[$idPath]->getRequestPath();
73
+ }
74
+ }
75
+ /**
76
+ * check if current generated request path is one of the old paths
77
+ */
78
+ $fullPath = $requestPath.$suffix;
79
+ $finalOldTargetPath = $this->getResource()->findFinalTargetPath($fullPath, $storeId);
80
+ if ($finalOldTargetPath && $finalOldTargetPath == $idPath) {
81
+ $this->getResource()->deleteRewrite($fullPath, $storeId);
82
+ return $fullPath;
83
+ }
84
+ }
85
+ /**
86
+ * Check 2 variants: $requestPath and $requestPath . '-' . $productId
87
+ */
88
+ $validatedPath = $this->getResource()->checkRequestPaths(
89
+ array($requestPath.$suffix, $requestPath.'-'.$product->getId().$suffix),
90
+ $storeId
91
+ );
92
+
93
+ if ($validatedPath) {
94
+ return $validatedPath;
95
+ }
96
+ /**
97
+ * Use unique path generator
98
+ */
99
+ return $this->getUnusedPath($storeId, $requestPath.$suffix, $idPath);
100
+ }
101
+ }
102
+ }
app/code/community/Activo/Categoryurlseo/etc/config.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Activo_Categoryurlseo>
5
+ <version>1.0.0</version>
6
+ </Activo_Categoryurlseo>
7
+ </modules>
8
+
9
+ <global>
10
+ <helpers>
11
+ <categoryurlseo>
12
+ <class>Activo_Categoryurlseo_Helper</class>
13
+ </categoryurlseo>
14
+ <catalog>
15
+ <rewrite>
16
+ <category>Activo_Categoryurlseo_Helper_Category</category>
17
+ </rewrite>
18
+ </catalog>
19
+ </helpers>
20
+ <models>
21
+ <categoryurlseo>
22
+ <class>Activo_Categoryurlseo_Model</class>
23
+ </categoryurlseo>
24
+ <catalog>
25
+ <rewrite>
26
+ <url>Activo_Categoryurlseo_Model_Url</url>
27
+ </rewrite>
28
+ </catalog>
29
+ </models>
30
+ </global>
31
+ <adminhtml>
32
+ <acl>
33
+ <resources>
34
+ <admin>
35
+ <children>
36
+ <system>
37
+ <children>
38
+ <config>
39
+ <children>
40
+ <activo_categoryurlseo>
41
+ <title>SEO Friendly Category</title>
42
+ </activo_categoryurlseo>
43
+ </children>
44
+ </config>
45
+ </children>
46
+ </system>
47
+ </children>
48
+ </admin>
49
+ </resources>
50
+ </acl>
51
+ </adminhtml>
52
+ <default>
53
+ <activo_categoryurlseo>
54
+ <global>
55
+ <enabled>1</enabled>
56
+ <toplevel></toplevel>
57
+ </global>
58
+ </activo_categoryurlseo>
59
+ </default>
60
+ </config>
app/code/community/Activo/Categoryurlseo/etc/system.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category
23
+ * @package _home
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <tabs>
30
+ <activo translate="label">
31
+ <label>Activo Extensions</label>
32
+ <sort_order>101</sort_order>
33
+ </activo>
34
+ </tabs>
35
+ <sections>
36
+ <activo_categoryurlseo translate="label" module="categoryurlseo">
37
+ <class>separator-top</class>
38
+ <label>SEO Friendly Category</label>
39
+ <tab>activo</tab>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>67</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <groups>
46
+ <global translate="label">
47
+ <label>SEO Friendly Category Oprions</label>
48
+ <expanded>1</expanded>
49
+ <sort_order>100</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <fields>
54
+ <enabled translate="label">
55
+ <label>Enabled?</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>10</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ <comment>Select Yes if you wish to ignore the parent category(s) in the Category URLs. Notice once you change this value you may need to reindex the Catalog URL Rewrites.</comment>
63
+ </enabled>
64
+ <toplevel translate="label">
65
+ <label>Manual Top Level</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>20</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <comment>Add a top level manual category that will apply to all products accross the store. No need for the preceeding forward slash, add a trailing forward slash if needed.</comment>
72
+ </toplevel>
73
+ </fields>
74
+ </global>
75
+ </groups>
76
+ </activo_categoryurlseo>
77
+ </sections>
78
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>activo_categoryurlseo</name>
4
- <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
@@ -11,8 +11,8 @@
11
  <notes>Flattens the SEO structure of your entire catalog: fixed double slash bug in certain cases.</notes>
12
  <authors><author><name>Activo Extensions</name><user>activo</user><email>extensions@activo.com</email></author></authors>
13
  <date>2012-10-23</date>
14
- <time>18:17:19</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Activo_Categoryurlseo.xml" hash="cbb2d56a19efe3658ff0b6bf21376dd3"/></dir></target></contents>
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_categoryurlseo</name>
4
+ <version>1.0.4.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
11
  <notes>Flattens the SEO structure of your entire catalog: fixed double slash bug in certain cases.</notes>
12
  <authors><author><name>Activo Extensions</name><user>activo</user><email>extensions@activo.com</email></author></authors>
13
  <date>2012-10-23</date>
14
+ <time>19:05:57</time>
15
+ <contents><target name="magecommunity"><dir name="Activo"><dir name="Categoryurlseo"><dir><dir name="Helper"><file name="Category.php" hash="15ae9939d3b789f194747ffd2163e204"/><file name="Data.php" hash="6892bf5f068f01ecbe4bc746ed0be85b"/></dir><dir name="Model"><file name="Url.php" hash="2e970a0b97c40f38d46da150410170d9"/></dir><dir name="etc"><file name="config.xml" hash="c6b25932abab4588478b2ccf46f5ee36"/><file name="system.xml" hash="d8d6fa1b7e04ada0c492b3738b6d9de7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Activo_Categoryurlseo.xml" hash="cbb2d56a19efe3658ff0b6bf21376dd3"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>8.0.0</max></php></required></dependencies>
18
  </package>