laserdance Posted October 8, 2012 Share Posted October 8, 2012 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 More sharing options...
prestashopninja Posted October 12, 2012 Share Posted October 12, 2012 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. 1 Link to comment Share on other sites More sharing options...
The Ge Posted October 12, 2012 Share Posted October 12, 2012 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 More sharing options...
prestashopninja Posted October 12, 2012 Share Posted October 12, 2012 Hi, The method Category::hideCategoryPosition() doesn't exist anymore on version 1.5.1.0 Link to comment Share on other sites More sharing options...
laserdance Posted October 13, 2012 Author Share Posted October 13, 2012 Nice, thank you guys! Prestashopninja's answer worked for me. Link to comment Share on other sites More sharing options...
mux Posted November 8, 2012 Share Posted November 8, 2012 Thank you guys.... i worked for me as well Link to comment Share on other sites More sharing options...
niaguis Posted March 1, 2013 Share Posted March 1, 2013 (edited) Thank you Gabi T and Prestashopninja your solution worked for me too. Edited March 1, 2013 by niaguis (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts