views:

65

answers:

2

Hi,

I have a problem with magento product links. When I search a product and then click the product link, Magento redirects me to index.php/test666.html when it supposed to be index.php/products/grocery/miso-soup/test666.html.

is it possible to force Magento use product's full path?

Added:

I can't get it to work by enabling 'Use Categories Path for Product URLs'. So I ended up with the following code.

$categories = $_product->getCategoryIds();
$lastCategory = $_categoryModel->load(end($categories));

$urlPath = explode("/",$lastCategory->getUrlPath());

$urlPathCnt = count($urlPath)-1;
$urlPath[$urlPathCnt] = str_replace(".html","",$urlPath[$urlPathCnt]);
$productUrl = "/".implode("/",$urlPath)."/".$_product->getUrlKey().".html";

but I really don't like this way. It uses unnecessary resource. Any ideas??

+1  A: 

In the admin, go to System>Configuration>Catalog>Search Engine Optimizations and set Use Categories Path for Product URLs

Jonathan Day
@Jonathan Day// it is already set to 'Yes'
Moon
A: 

You may need to refresh the "Catalog URL Rewrites" index. The HTML may also be served from the cache, so refreshing it wouldn't hurt.

Chris Norton