Jump to content

After upgrade to 1.5: Call to undefined method Category::hideCategoryPosition()


Recommended Posts

Hello, after upgrade shop from v. 1.4 to 1.5 my custom-made module, which I bought, stopped working with error: Call to undefined method Category::hideCategoryPosition().

 

In code it looks like this:

 

foreach ($result as $row) {

if ($row['level_depth'] == 1) $categories[$row['id_category']] = Category::hideCategoryPosition($row['name']);

else $categories[$row['id_category']] = $categories[$row['id_parent']] . " - " . Category::hideCategoryPosition($row['name']);

}

 

 

Is it something, what can I fix by myself, or I must contact (paid) support to fix it? I suppose ony small change in database, I'm not programmer, but I can fix small pieces of code..

 

Thanks,

T.

Link to comment
Share on other sites

Hello,

 

I came accross the same issue while converting a theme to 1.5 and found out Category::hideCategoryPosition() method is deprecated. I don't know if there is/will be a replacement for that, but a quick fix is as follows:

 

1. Open your module's main class. If your module's name is myModule, the file and class names will also be the same. (myModule/myModule.php)

 

2. Inside your class, copy this method I borrowed from a PS 1.4.x's Category class:


public static function hideCategoryPosition($name)
{
return preg_replace('/^[0-9]+\./', '', $name);
}

 

3. Replace throughout the file myModule.php

Category::hideCategoryPosition

with

self::hideCategoryPosition

 

I hope this helps.

  • Like 1
Link to comment
Share on other sites

Guys, have you tried to simply comment out the deprecated function? Like:

foreach ($result as $row) {
if ($row['level_depth'] == 1) $categories[$row['id_category']] = /*Category::hideCategoryPosition(*/$row['name']/*)*/;
else $categories[$row['id_category']] = $categories[$row['id_parent']] . " - " . /*Category::hideCategoryPosition(*/$row['name']/*)*/;
}

 

It worked for me. Or you could delete the function call, I'm just reluctant to delete code.

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...
×
×
  • Create New...