Created
June 18, 2014 14:11
-
-
Save dinhkhanh/5a7224c95d661fe29e37 to your computer and use it in GitHub Desktop.
Always include catalog in product url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php | |
=================================================================== | |
--- app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php (revision 2102) | |
+++ app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php (working copy) | |
@@ -553,7 +553,11 @@ | |
->from($this->getTable('core/url_rewrite'), array('product_id', 'request_path')) | |
->where('store_id=?', Mage::app()->getStore()->getId()) | |
->where('is_system=?', 1) | |
- ->where('category_id=? OR category_id is NULL', $this->_urlRewriteCategory) | |
+// excluding this clause to facilitate one URL per product, and one that includes the category | |
+// if a product has multiple categories, the first one (by category_id) will be used | |
+// in most cases you'll probably only have one category because you only want one page per product for SEO reasons | |
+// for maximum link juice, no possibility of duplicate content, and a less confusing store | |
+// ->where('category_id=? OR category_id is NULL', $this->_urlRewriteCategory) | |
->where('product_id IN(?)', $productIds) | |
->order('category_id DESC'); // more priority is data with category id | |
$urlRewrites = array(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment