Xavier
Xavier

Reputation: 159

Magento get category url from ID without ?SID=

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?

Upvotes: 2

Views: 3903

Answers (3)

Alex
Alex

Reputation: 767

    $params = array(
        '_nosid' => true
    );

    $url = Mage::getUrl('*/*/*', $params);

Upvotes: 6

Deepak Mankotia
Deepak Mankotia

Reputation: 4564

You can configure this from admin panel :

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

Upvotes: 1

user439441
user439441

Reputation:

Try this:

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

Upvotes: 4

Related Questions