Reputation: 95
does getProductUrl return product url with the category path, how can i get it to work like that, it seems others will suggest to use a helper, but i guess it is not the only way.
Upvotes: 2
Views: 3094
Reputation: 61
The proposed answer did not work on my Magento version (1.9).
Here is what worked for me:
$category = Mage::getModel('catalog/category')->load($categorieId);
Mage::unregister('current_category');
Mage::register('current_category', $category);
$product->getProductUrl();
Upvotes: 1
Reputation: 5660
I haven't checked it but I am quite sure the product needs to know about the category.
$product->setCategoryId($categoryId)->getProductUrl();
Upvotes: 2