Jump to content

Delete class-index file when cache is empty


tryple

Recommended Posts

(Solved) Hello everyone,

 I created an override of the Cart.php class to modify the getSummary function and to be able to retrieve a new variable to display in the cart summary.

Well, everything works correctly until from the backoffice I delete the cache. Then it gives me error in eval () of the smarty indicating that the new variable is not created.

I enter the hosting and delete the class_index.php file from the cache folder. From here everything begins to work again.

It is as if every time I empty the cache I ignored the function modified with the override.

In the overloaded function I have copied and pasted as is. I've just added a new variable that reads from an sql query.

Do you know some why? Do I have to declare the variable somewhere or have I misconfigured prestashop?

 

Thank you very much in advance.

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

  • 4 weeks later...

The problem if this behavior is at the end: just faulty code. When class_index.php is deleted, prestashop checks all folders for possible overrides and builds its code. At this stage, any php warning or error results in error in eval () of the smarty.

 

Solution: fix the code of the override or module which causes this error. The name of the variable missing might help to find the piece of code. We usually use a complex grep on linux based systems to search for a specific code context.

Link to comment
Share on other sites

Thank you very much for answering.
In the code all I can do is check that the variable exists so that it does not show it in such a case.
According to indicas with the grep would be a problem in the hosting of the web?
Every time I do a cache empty or change the method of compiling the templates in the prestashop backoffice I have to delete the class_index.php

Link to comment
Share on other sites

According to indicas with the grep would be a problem in the hosting of the web?

this was not understood by me.

 

many of these problems are caused by not using or not using the proper way with isset.

 

Every time I do a cache empty or change the method of compiling the templates in the prestashop backoffice I have to delete the class_index.php

And this looks like a buggy installation:

Link to comment
Share on other sites

The file class_index.php must only be deleted when installing new overrides or deleting existing ones. If you have to delete the file after every cache delete, there is some bug in your installation. It's normally not needed to delete this file when you delete the cache.

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...