Magento getting a products rewritten URL
Magento getting a products rewritten URL
To get the request path of a single product you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php $oProduct = Mage::getModel('catalog/product')->load($productId); var_dump( $oProduct->getUrlPath() ); To get the target path, you can use this: $oProduct = Mage::getModel('catalog/product')->load($productId); $oRewrite = Mage::getModel('core/url_rewrite')->loadByRequestPath( $oProduct->getUrlPath() ); var_dump( $oRewrite->getTargetPath() ); ?> |
Similarly Request path by Id Path
1 2 3 4 |
<?php $oProduct = Mage::getModel('catalog/product')->load($_product->getId()); $oRewrite = Mage::getModel('core/url_rewrite')->loadByIdPath($oProduct->getCanonicalUrl()); $pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName(); if($pageIdentifier=='catalogsearch_result_index'){?> |