DD_DD2 Posted April 20, 2017 Share Posted April 20, 2017 Hello, I implemented an override of the function filterOutField from SpecificPrice Class. The new file is located in \override\classes\ and its content looks like that: class SpecificPrice extends SpecificPriceCore { protected static function filterOutField($field_name, $field_value, $threshold = 1000000) { ... } } I deleted /app/cache/dev/class_index.php and /app/cache/prod/class_index.php. Nothing happens this override doesn't work. Does anyone know if this override is allowed in PS 1.7, and if yes why it doesn't work ? Thanks in advance for your help. Link to comment Share on other sites More sharing options...
danieldmw Posted May 26, 2017 Share Posted May 26, 2017 Hello, I implemented an override of the function filterOutField from SpecificPrice Class. The new file is located in \override\classes\ and its content looks like that: class SpecificPrice extends SpecificPriceCore { protected static function filterOutField($field_name, $field_value, $threshold = 1000000) { ... } } I deleted /app/cache/dev/class_index.php and /app/cache/prod/class_index.php. Nothing happens this override doesn't work. Does anyone know if this override is allowed in PS 1.7, and if yes why it doesn't work ? Thanks in advance for your help. Same problem with Order.php override on PS 1.7.1 Link to comment Share on other sites More sharing options...
Masteries Posted May 26, 2017 Share Posted May 26, 2017 From what I know, overrides are no longer supported in Prestashop 1.7. Or rather, let me re-phrase that, overrides are still usable to some degree: "[..] overrides work as usual on all classes that have no namespace (so you can still override Product, Address, etc.)." Quote from: http://build.prestashop.com/news/prestashop-1-7-faq/#can-developers-still-use-overrides-in-17 Also, a quote from NemoPS's blog: "[..]PrestaShop 1.7 will not use overrides anymore. The article states legacy architecture will still be usable; however the back office’s Product and Modules page will not allow their usage. Into human language, it means all modules currently (wisely) using overrides will have to drop the system in future 1.7 versions." However, I'm not very knowledgeable in using overrides so I'm unsure if what you're trying to do applies to this. Link to comment Share on other sites More sharing options...
DD_DD2 Posted May 29, 2017 Author Share Posted May 29, 2017 Thank you Masteries. but as far as I can see, SpecificPrice has no namespace. Hence it should work according to the PS Prestashop you refered to (http://build.prestas...overrides-in-17) Link to comment Share on other sites More sharing options...
Masteries Posted May 29, 2017 Share Posted May 29, 2017 Thank you Masteries. but as far as I can see, SpecificPrice has no namespace. Hence it should work according to the PS Prestashop you refered to (http://build.prestas...overrides-in-17) Welp, I guess you could always just make the modification to core files instead of using overrides. Link to comment Share on other sites More sharing options...
DD_DD2 Posted May 29, 2017 Author Share Posted May 29, 2017 Yes, i finally did it but it's a pity proceeding like that Link to comment Share on other sites More sharing options...
PR1989 Posted August 17, 2017 Share Posted August 17, 2017 how did you do it, can you tell us please Link to comment Share on other sites More sharing options...
DD_DD2 Posted August 18, 2017 Author Share Posted August 18, 2017 @1989 As the override doesn't work despite no namespace, I simply opened the /classes/SpecificPrice.php and changed the lines I wanted to change. The pity doing that is that it will not remain changed through a one click update Link to comment Share on other sites More sharing options...
bellini13 Posted August 18, 2017 Share Posted August 18, 2017 (edited) SpecificPriceCore extends the ObjectModel, and ObjectModel uses the following namespace use PrestaShop\PrestaShop\Adapter\ServiceLocator; Perhaps the namespace from the parent class is preventing the override, or perhaps the fact that ObjectModelCore implements something from the NEW architecture interfers... abstract class ObjectModelCore implements \PrestaShop\PrestaShop\Core\Foundation\Database\EntityInterface If you can't do something with the override, then try doing it with a module. If a module cannot do it, then the only thing you can do is what you have done. Try submitting an enhancement request to Prestashop using their forge, and perhaps they can add another module hook to solve what you are trying to accomplish. Edited August 18, 2017 by bellini13 (see edit history) 1 Link to comment Share on other sites More sharing options...
Daniele0884 Posted April 25, 2018 Share Posted April 25, 2018 Hi everyone, i'm looking for help for a question, but nobody help to me, i try ask here because i have see conversation about Specific price. I have PS 1.7.2.4, i would like make specific price product for discount, by Total cart amount, and not by Quantity product. It's possible make any change for make this? Please someone can help me to make any changes to any files, for this? Thanks Link to comment Share on other sites More sharing options...
Rémi Posted May 7, 2018 Share Posted May 7, 2018 Hi everyone, I got the same problem. I need to add attributes to an class (seller) of a module (JA MARKETPLACE). It seems logical to me that the proper way is to override the class. How i supposed to do if we can't ? What is the best solution to have a coherent and reusable structure and a durable solution ? Thank you for your answers. Link to comment Share on other sites More sharing options...
stevell Posted June 11, 2018 Share Posted June 11, 2018 On 5/27/2017 at 5:02 AM, danieldmw said: Same problem with Order.php override on PS 1.7.1 Have you added the <?php to the start of the file? Link to comment Share on other sites More sharing options...
Pierre Belin Posted January 4, 2020 Share Posted January 4, 2020 This one was helpfull. I added it once to make it work, then I could comment it and it's still working ! Something was broken down there On 8/18/2017 at 1:15 PM, bellini13 said: SpecificPriceCore extends the ObjectModel, and ObjectModel uses the following namespace use PrestaShop\PrestaShop\Adapter\ServiceLocator; Perhaps the namespace from the parent class is preventing the override, 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