Jump to content

Overrides and symfony


Recommended Posts

Not sure this is the best place to post this. I would like to continue to develop in Prestashop and maybe contribute to it. But before I decide on that there was a change in 1.7 that left me worried and wanted to get some answers if possible.
I already now that the src folder doesn't support overrides.
But is this a temporary thing? Will it be available in the future?
More and more classes are used from the src folder and sometimes we need to change their behaviour but would also like to be compatible for future upgrades.
Also, if other developers have this concern, please share you thoughts and advice on how are you going to work with this.
Best regards

Link to comment
Share on other sites

I'm also new to prestashop 1.7.

at this time. You can still override what you want (no ?).
I think every customizations could be made using hooks, without overrides.
And maybe, the code will use injection typed with interface, so the dependency injector will be able to inject your dependency instead of the original one. (see symfony or laravel or any dependency injection container)

Link to comment
Share on other sites

1 hour ago, seb776 said:

at this time. You can still override what you want (no ?).
And maybe, the code will use injection typed with interface, ...


You can't override the classes in the src folder. The only option is to chages the files in that folder, which gets changed again on updates, and it's not recomended to to either.
When I read that prestashop was migrating to symfony I thought it would be possible to use the dependency injection to override behaviours, by creating our own PriceFormatter for example. Not sure its already possible with the structure of prestashop.

Link to comment
Share on other sites

We could be doing it the wrong way. But one of the times we had to change in the src was because of the src\Core\Product\Search\urlFragmentSerializer.
A store with 2 main categories (Men and Women) both have a sub category with same name (Shirts).
In the faceted search, if we picked Shirts as a filter, it would show both categories as selected.
To avoid this, we needed to add the category id, and change the unserializeListOfStrings and serialize from the file mentioned, and some other changes.

Link to comment
Share on other sites

Just found what might be a bug, and of a file theme in src/PrestashopBundle/Resources/views/Admin/Product (in v1.7.2)
The page https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/ mentions the hooks displayAdminProductsQuantitiesStepBottom, but I've made a module with no success. When checking the hook info, viewed the file and there is no mention to that hook. So, if I change this file to include it, it will be lost my changes on future updates.
Also, after finding that this file, it makes me wonder if will we be able to customize backoffice as the old versions allowed (of course many don't use custom back office themes)

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