5

In Magento I have this to get the the url of a category from its ID

$categoryLink = Mage::getModel("catalog/category")->load(10)->getUrl();

It works but at the end of url there is ?SID=somenumber.

I know I could remove it from

System > Configuration > Web > Session Validation Settings > Use SID on Frontend

But I want to keep it active, so how can i get the url of category without the ?SID=somenumber?

2 Answers 2

7

Using strpos and substr function, it works

$categoryLink = Mage::getModel("catalog/category")->load(10)->getUrl();
$pos = strpos($categoryLink, '?');
$categoryLink = ($pos>0) ? substr($categoryLink, 0, $pos) : $categoryLink;
1

You can configure this from admin panel :

Go to Admin == System == Configuration == Web == Session Validation Settings and disable config Use SID on Frontend = No

1
  • Thank you for your help, but like I wrote I knew this solution, but i need to keep it active! Do you have other suggest?
    – Xavier
    Commented May 18, 2015 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.