Magento Tag Url Rewrite and Generate

I added lots of rewrite rules for tags in Magento. For example,

Request Path: tag/abc Target Path: tag/product/list/tagId/7/ Type: Custom

Everything is going well in the request and response. But I am wondering how to change the tag URL in the front? Although the rewrite rules run perfectly it will not change the URL which has been rewritten.

I found the getTaggedProductsUrl() method in tag module and eventually, like others, it calls getUrl() method in core/url Model. I tried to add, '_use_rewrite' => true to the route params. But it does not generate the right URL.

I really would like to know what's wrong about this!

-------------Problems Reply------------

If you rewrite the tag/tag model and override the getTaggedProductsUrl() with the following it will work:

public function getTaggedProductsUrl()
{
$fullTargetPath = Mage::getUrl('tag/product/list', array(
'tagId' => $this->getTagId(),
'_nosid' => true
));
$targetPath = substr($fullTargetPath, strlen(Mage::getBaseUrl()));
$rewriteUrl = Mage::getModel('core/url_rewrite')->loadByIdPath($targetPath);
if ($rewriteUrl->getId()) {
return $rewriteUrl->getRequestPath();
}
return $fullTargetPath;
}

This is assuming you are using the target path without the base url as the "ID path" and the "Target Path" property, e.g tag/product/list/tagId/30/.
If you don't want to duplicate that setting then you will need to use the tag resource model and manually adjust the SQL to match the target_path column instead the id_path, because the resource model doesn't come with a method predefined for you.
Still, you can use the Mage_Tag_Model_Resource_Tag::loadByRequestPath()method as a reference.

Category:magento Views:0 Time:2011-11-30
Tags: magento

Related post

  • Magento Tag Url-Rewrite? 2011-09-14

    I am trying to make a permanent url rewrite for tags in Magento. Unfortunately with url-rewrite it won't work. The path to the tag is: magento/tag/product/list/tagId/1/ I want to make a url rewrite to: magento/tag/bathroom Where do I have to make cha

  • Magento Catalog URL rewrites stuck on processing 2011-03-15

    As the title says my Catalog URL rewrites indexer is stuck on processing. I've tried everything and I just can't find a solution to this. Does anyone know a solid fix for this? I've tried truncating core_url_rewrite table and deleting the locks but i

  • Magento Catalog URL Rewrites - Long time to index 2012-03-07

    We are using magento 1.4.1 for our store, with 30+ categories and 2000+ products, every time i try to reindex the indexes "Catalog URL Rewrites" takes longer time to complete, please suggest us on how we can improve its speed? --------------Solutions

  • Magento filters url rewrite 2011-03-29

    I've got one task about Layer Navigation block on site, powered by Magento. We want to make a SEO friendly URL's in filters: Now there are links like mymagazine.ru/category/subcategory1?manufacturer=1926 As you see - manufacturer=1926 is a GET-parame

  • Magento Apache Mod Rewrite URL 2012-04-09

    I have a refer a friend module that gives people a long referral url I want to shorten it to make it easier for people to type, but can figure out how to get it done in .htaccess Below is the rewrite section of my .htaccess I want to redirect /ap/* t

  • url rewriting + Asp.Net Login Form = Death 2009-03-06

    on our site we do url rewriting to generate massive amounts of database generated pages. on every page, there is a Login control for users. like this: Internal aspx page: /DB.aspx?id=123 User visible url: /ABC/123.aspx, /ABC/456.aspx ... (url rewritt

  • How to auto-generate Magento URL Rewrites? 2012-03-30

    I've adapted the Ebizmarts Customerprofile module for a project I'm working on and I need to automatically rewrite any requests to: mymagestore.com/profile/USERNAME to mymagestore.com/customerprofile/account/view/username/USERNAME Sounds simple enoug

  • jsessionid is occured in all urls which are generated by jstl tag 2009-06-25

    I've got some strange bug: when I open page first time in some browser all references has jsessionid parameter (like <a href="/articles?name=art&jsessionid=5as45df4as5df"..>). When I press F5 or refresh the page by any other ways all that s

  • Magento CMS URL tag language independent? 2011-05-18

    Is it somehow possible to have language independent CMS tags in Magento? This works in both storeviews: {{store url='catalog/category/view/id/10'}} output: www.my-domain.de/catalog/category/view/id/10 But it would be better if the output would be lik

  • ASP.NET: images broken when combining URL Rewriting, asp:ImageButton and html base tag 2010-04-23

    I'm using URL Rewriting under ASP.NET 4 (using ISAPI_Rewrite) and I'm finding that that some of my images are not loading as .NET does not seem to understand I'm using an html BASE tag (pretty standard and essential when doing URL Rewriting): eg in m

  • reindex Catalog URL Rewrites in magento never ends 2010-08-02

    I've imported 6K categories and 16K products to magento using a custom import profile. When I'm trying to reindex everything works except for 'Catalog URL Rewrites' that keep showing PROCESSING but never completes. log and exceptions files don't show

  • Url rewriting causes Magento admin to become inaccessible 2010-10-29

    I have magento in a subdirectory in the root and if I set the secure base url and secure base url link to the correct shared ssl url to enable secure pages I have no problem in the FRONTEND. The pages displays as they should. However when I try to ac

  • magento indexControllor.php url rewriting not working properly 2010-11-24

    Hi i build a indexcontrollor in module brand like this class Blank_Brand_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { echo 'Foo Index Action'; $this->addaction(); } public function addAction() { echo

  • URL rewriting for Magento module 2011-01-22

    I have created a New Module in Magento and named it as "article". It has two Front end controllers index and article. And in the article controller i have an action called "archives" to list the articles on the front end / website based on the archiv

  • Magento URL rewrite option 2011-03-22

    I want to modify the Catalogsearch of magento. So i followed this inchoo article - http://inchoo.net/ecommerce/magento/advanced-search-in-magento-and-how-to-use-it-in-your-own-way/ and i got it worked. So my url became - www.site.com/catalogsearch/cu

  • which tables are affected by the Catalog URL Rewrites index in Magento? 2011-03-24

    Pretty straightforward question, which tables are affected by the Catalog URL Rewrites index in Magento? Each time I run this index it takes a long time to run and the admin status for the index gets stuck on PROCESSING. I have tried to find lock tab

  • how to rewrite or generate url like twitter and facebook in java 2011-07-10

    how to rewrite or generate url like twitter and facebook in java.... Example : https://www.facebook.com/username, https://www.twitter.com/username is there any java framework for this? If anyone's got any ideas on how I could do this, or examples to

  • What is the issue with this url rewrite tag used in JBoss? 2011-12-19

    I am re-writing the URLs on JBoss by giving the following rewrite tag in standalone.xml <rewrite pattern="^/myapp/resources/([0-9]+)/(.+)$" substitution="/myapp/resources/$2" /> The above URL rewrite rule is expected to map the following URL: h

  • magento, error when reindexing Catalog URL Rewrites 2012-01-20

    All this afte rupgrading from 1.4.1 I get a quite specific error message: Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'product/19-1-2' for key 'UNQ_CORE_URL_REWRITE_

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.186 (s). 11 q(s)