Jump to content

Override does not work for Product.php Class (v 1.5.2)


bluego78

Recommended Posts

Hi,

i'm trying to do a simple override to Product Class but this doesn't work.

 

In override/classes/Product.php i have

 

class Product extends ProductCore
{

       public function my_function()
       {
              return 'hello world';
       }
}

 

If i try to call from a module Product::my_function(); the page return error on the browser.

 

I've tried also public static function but it's the same thing.... and i've tried also to do:

 

$p = new Product();
$p->my_function();

 

Nothing to do...

Where is my mistake?

 

Please help me!

Link to comment
Share on other sites

Today I've installed prestashop 1.5.2. At me doesn't work to override the FrontController that came with an overridden file... To do that I modified the base file to do an redirect into maintenance method.

 

I know isn't a good choice but is for moment. I've trusted in prestashop but came to be useless.

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

I found the solution for my problem: I just had to delete "cache/class_index.php" (eventough I hadn't enabled cache), so that this file get's re-created (happens automatically).

 

The problem was that I renamed the override-folder to debug a problem. And that appears to change that file I mentioned above so that prestashop doesn't recognize the override-folder anymore when you rename it back.

 

Try it out.

  • Like 3
Link to comment
Share on other sites

  • 6 months later...

Many Thanks Big_Berny, you found the solution for me :).

I removed file cache/class_index.php and it working...

It is really helpful for me it is just similar to life saving help.

 

 

 

It doesn't matter you have enabled cache or not. I found after each time you override class or controller you have to delete that file

to take effect of overriding once you run site that file automatically generated that having record of all your core as well as overridden controller and class file details. If you are changing in same overridden class/ controller you don't need to delete file again and again.

Edited by vivek tripathi (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...