Jump to content

link->getCategoryLink throws a strange warning


stratboy

Recommended Posts

Hi, with this line of code:

 

p($link->getCategoryLink(new Category(3)));

 

I get the requested permalink, but also this warning:

 

Warning: trim() expects parameter 1 to be string, array given in [...]/classes/Tools.php on line 981

 

So, what's the matter here? If I look at the Link::getCategoryLink() source, I see that I must pass the category Object, since the category ID (that instead doesn't throw any warning) is deprecated.

 

Any idea?

Edited by stratboy (see edit history)
Link to comment
Share on other sites

I believe these are your issues

 

$params['meta_keywords'] = Tools::str2url($category->meta_keywords);

$params['meta_title'] = Tools::str2url($category->meta_title);

 

Can you try to dump those 2 variables before those 2 lines? (they're in the getcategorylink funcion)

Link to comment
Share on other sites

I believe these are your issues

 

$params['meta_keywords'] = Tools::str2url($category->meta_keywords);

$params['meta_title'] = Tools::str2url($category->meta_title);

 

Can you try to dump those 2 variables before those 2 lines? (they're in the getcategorylink funcion)

 

Yes, the dump is something like this:

 

array(1) {   [1]=>   string(0) "" }

 

So they're array not string.

 

Though, it's just prestashop output. getCategoryLink wants a category object, and a category object features those properties as array, not string. I guess it's maybe a little bug? For now I'll continue to use the ID instead, even if it's officially deprecated.

 

Thank you!

Edited by stratboy (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...