promt Posted April 21, 2017 Share Posted April 21, 2017 Hi all, Is it possible to override classes in src folder? Especially I need to add an additional field to the OrderPresenter's present() method which is located at /src/Adapter/Order/OrderPresenter.php PrestaShop version: 1.7.0.6 Thank you in advance for any help! BR,Paulius Link to comment Share on other sites More sharing options...
bruno750 Posted April 26, 2017 Share Posted April 26, 2017 Hi, have you find a solution to override src class ? if yes ! can you show me the way thank you Link to comment Share on other sites More sharing options...
bellini13 Posted April 26, 2017 Share Posted April 26, 2017 I believe the answer is simple. You do not override them, Prestashop did not build support for overriding new core in v1.7 Link to comment Share on other sites More sharing options...
phinq1910 Posted April 27, 2017 Share Posted April 27, 2017 Same @bellini13 They are updated some hook for replace overriding. From 1.7+, override is bad. Link to comment Share on other sites More sharing options...
vekia Posted April 27, 2017 Share Posted April 27, 2017 Overrides of other things than classes/controllers/modules with /override/ directory is not available anymore. is it good? well, in my opinion no, it is not. But in this case we cant do anything, unfortunately. 4 Link to comment Share on other sites More sharing options...
Artemis909 Posted September 1, 2017 Share Posted September 1, 2017 (edited) Is this what you looking for? Presta 1.7 overriding-> PrestaShop’s controllers are all stored in the /controllers folder, and use the “Core” suffix. For instance, when working with the Category controller: File: /controllers/CategoryController.php Class: CategoryControllerCore In order to override a controller, you must first create a new class without the “Core” suffix, and place its file in the /override/controllers folder. For instance, when overriding the Category controller: File: /override/controllers/front/CategoryController.php Class: CategoryController Do not forget to delete cache in admin... http://developers.prestashop.com/module/04-DivingIntoPSCoreDevelopment/03-ControllersWithinPrestaShop.html Edited September 1, 2017 by Artemis909 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted September 2, 2017 Share Posted September 2, 2017 people need to read... Is it possible to override classes in src folder? the answer is no Link to comment Share on other sites More sharing options...
renaud2263 Posted March 9, 2018 Share Posted March 9, 2018 Is it always impossible with the 1.7.3 ? No method ? Even with hook ? Link to comment Share on other sites More sharing options...
bellini13 Posted March 9, 2018 Share Posted March 9, 2018 it is not possible to override There may be hooks, you would have to look at the code and determine if there are hooks to use Link to comment Share on other sites More sharing options...
renaud2263 Posted March 9, 2018 Share Posted March 9, 2018 I need to override to modify the product form in the BO Link to comment Share on other sites More sharing options...
bellini13 Posted March 9, 2018 Share Posted March 9, 2018 you cannot override the classes in the src folder you will need to find some other method to do what you would like to do Link to comment Share on other sites More sharing options...
innercode Posted January 8, 2019 Share Posted January 8, 2019 (edited) It looks like PS team has 0 experience working with shops and clients. If they are going to move Core and disallow overrides.. either migration to another platform will be needed OR no upgrades for client shops due to modified code. Maintaining such mess would be a pain. Maybe we OR other devs will think how to do overrides to src.. Edited January 8, 2019 by innercode (see edit history) 1 Link to comment Share on other sites More sharing options...
theDoris Posted March 12, 2019 Share Posted March 12, 2019 Is there any change? I also need override file from src folder in custom module for 1.7.5. Link to comment Share on other sites More sharing options...
Janett Posted May 27, 2019 Share Posted May 27, 2019 What is your Prestashop version ? What are your needs ? Impossible to suggest you some hooks if we don’t know your needs... Override is not available anymore for src folder due to architecture change. But we can use hooks or we can create your own implementation based on same class interface : http://build.prestashop.com/news/prestashop-in-2019-and-beyond-part-1-current-architecture/ Link to comment Share on other sites More sharing options...
rewuxiin Posted February 17, 2020 Share Posted February 17, 2020 On 5/27/2019 at 9:37 AM, Janett said: What is your Prestashop version ? What are your needs ? Impossible to suggest you some hooks if we don’t know your needs... Override is not available anymore for src folder due to architecture change. But we can use hooks or we can create your own implementation based on same class interface : http://build.prestashop.com/news/prestashop-in-2019-and-beyond-part-1-current-architecture/ Hey. I have exactly the same problem. PS 1.7.6.3 I want to hide the delivery if it is free, but only the value gets into the template and checking all languages for the text “Free” is very difficult In src "src/Adapter/Presenter/Cart/CartPresenter.php" $subtotals['shipping'] = array( 'type' => 'shipping', 'label' => $this->translator->trans('Shipping', array(), 'Shop.Theme.Checkout'), 'amount' => $shippingCost, 'value' => $shippingCost != 0 ? $this->priceFormatter->format($shippingCost) : $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'), ); replace if($shippingCost != 0){ $subtotals['shipping'] = array( 'type' => 'shipping', 'label' => $this->translator->trans('Shipping', array(), 'Shop.Theme.Checkout'), 'amount' => $shippingCost, 'value' => $shippingCost != 0 ? $this->priceFormatter->format($shippingCost) : $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'), ); } But how to do it right? Link to comment Share on other sites More sharing options...
Geimsdin Posted January 16, 2021 Share Posted January 16, 2021 On 2/17/2020 at 9:51 AM, rewuxiin said: Hey. I have exactly the same problem. PS 1.7.6.3 I want to hide the delivery if it is free, but only the value gets into the template and checking all languages for the text “Free” is very difficult In src "src/Adapter/Presenter/Cart/CartPresenter.php" $subtotals['shipping'] = array( 'type' => 'shipping', 'label' => $this->translator->trans('Shipping', array(), 'Shop.Theme.Checkout'), 'amount' => $shippingCost, 'value' => $shippingCost != 0 ? $this->priceFormatter->format($shippingCost) : $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'), ); replace if($shippingCost != 0){ $subtotals['shipping'] = array( 'type' => 'shipping', 'label' => $this->translator->trans('Shipping', array(), 'Shop.Theme.Checkout'), 'amount' => $shippingCost, 'value' => $shippingCost != 0 ? $this->priceFormatter->format($shippingCost) : $this->translator->trans('Free', array(), 'Shop.Theme.Checkout'), ); } But how to do it right? I think you are talking about frontend, no need to override anything, just play with your template (tpl file) to display or not the value. Simone Link to comment Share on other sites More sharing options...
SIWA_Fabian Posted November 10, 2021 Share Posted November 10, 2021 Honestly, the world would be a better place if overrides of src are possible. 1 Link to comment Share on other sites More sharing options...
[email protected] Posted September 29, 2022 Share Posted September 29, 2022 Hi! I need to do a modificaction in the file /src/PrestaShopBundle/Entity/Repository/StockRepository.php to modify the SQL for stock manager (line 257). The only way that I find is edit this file. But now you say is not possible to do a override, so what do you recommend me to do? Thanks! Link to comment Share on other sites More sharing options...
SIWA_Fabian Posted October 3, 2022 Share Posted October 3, 2022 On 9/29/2022 at 9:59 AM, [email protected] said: Hi! I need to do a modificaction in the file /src/PrestaShopBundle/Entity/Repository/StockRepository.php to modify the SQL for stock manager (line 257). The only way that I find is edit this file. But now you say is not possible to do a override, so what do you recommend me to do? Thanks! Hi! There is nothing you can really do. You can just edit the file directly without using the override mechanic of prestashop. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now