henryyao Posted February 8, 2015 Share Posted February 8, 2015 Hi nerds, I am confused on how prestashop classes infrastructure works. in many places like FrontControllerCore::init, it calls "new Product()" to load a product object. However, there is no class called Product and I tracked ProductCore::__constructor isn't called either. Does anyone know how a Product object is constructed? Thanks, Henry Link to comment Share on other sites More sharing options...
IgnacioSM Posted February 9, 2015 Share Posted February 9, 2015 What are you guys doing things on Sunday? For me, Sunday is a day to rest, just because I went out Saturday night, xD Here we go, You can create an object product calling "new Product()". it calles the ProductCore Class and that constructor, and creates a new Product. Don't worry about the "Core" suffix. Link to comment Share on other sites More sharing options...
henryyao Posted February 11, 2015 Author Share Posted February 11, 2015 I expect it to work like that, but when I make change to ProductCore, it has no impact to new Product() code path. I am wondering if I need to somehow re-compile or do some other magic? Link to comment Share on other sites More sharing options...
IgnacioSM Posted February 12, 2015 Share Posted February 12, 2015 You have to create a new Product Class that extends ProductCore...in another file class Product extends ProductCoreClass{ .... } http://doc.prestashop.com/display/PS16/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingaclass Link to comment Share on other sites More sharing options...
bellini13 Posted February 12, 2015 Share Posted February 12, 2015 I expect it to work like that, but when I make change to ProductCore, it has no impact to new Product() code path. I am wondering if I need to somehow re-compile or do some other magic? What exactly are you trying to do? What code change did you make? Link to comment Share on other sites More sharing options...
Raphaël Malié Posted February 12, 2015 Share Posted February 12, 2015 (edited) Hello, Everything is explained in this documentation : http://doc.prestashop.com/display/PS16/Overriding+default+behaviors It's a way to allow classes overrides. Regards, Ps : please don't call people "nerds", it's a pejorative word Edited February 12, 2015 by Raphaël Malié (see edit history) 1 Link to comment Share on other sites More sharing options...
henryyao Posted February 13, 2015 Author Share Posted February 13, 2015 Hi Raphael, Thanks for your reply. I am sorry if you feel offended by "nerds", we use that a lot in my company. I understand the way overrides works, thanks for your pointer. However, I still don't understand the following behavior: Let's take Translate::getAdminTranslation() function as example. It was called in AdminControllerCore::l() function, for translations of BO text fields. When I modify the return value in AdminControllerCore::l(), it shows in BO accordingly, everything makes sense. However, when I change the return value in TranslateCore::getAdminTranslation(), nothing happens. I even tried to delete the file /classes/Translate.php, everything still works properly. It makes me feel I am not modifying the right file. But I can't find any other place which have getAdminTranslation() function defined. Does what I described make any sense to you? Thanks, Henry Hello, Everything is explained in this documentation : http://doc.prestashop.com/display/PS16/Overriding+default+behaviors It's a way to allow classes overrides. Regards, Ps : please don't call people "nerds", it's a pejorative word Link to comment Share on other sites More sharing options...
bellini13 Posted February 13, 2015 Share Posted February 13, 2015 Again, show what you are doing. Provide the code from your override class... Also, after you install an override, Prestashop registers this override in a cache file. So once installed, refresh your back office dashboard and then open the /config/class_index.php file Search for the class that you have overriden (Translate) and confirm it has been registered. This is what it looks like when there is not an override registered 'Translate' => array ( 'path' => '', 'type' => 'class', 'override' => false, ), 'TranslateCore' => array ( 'path' => 'classes/Translate.php', 'type' => 'class', 'override' => false, ), 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