NemoPS Posted September 11, 2013 Share Posted September 11, 2013 Hi everybody! I just wrote a tutorial on how to plug modules into the products back office, and adding new fields without using overrides! I hope you can find it useful! Here it is! http://nemops.com/prestashop-products-new-tabs-fields/ Cheers! Fabio 1 Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 17, 2013 Share Posted September 17, 2013 Excellent tutorial as always Nemo. Only to point that it's interesting the use of the hook which is triggered when adding a product public function hookActionProductAdd($params) { $this->hookActionProductUpdate($params); } In that case is better use the $params instead of Tools::getValue('id_product') to completely reuse the hookActionProductUpdate public function hookActionProductUpdate($params) { $id_product = $params['product']->id; Link to comment Share on other sites More sharing options...
NemoPS Posted September 17, 2013 Author Share Posted September 17, 2013 Hi, and thank you! Uhm... I think I'm missing a point what do you mean? After all it's just about getting the product id Or....I'm missing the point as always Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 17, 2013 Share Posted September 17, 2013 And tank you again for sharing those in deep tutorials, I was thinking to put multi language to my tab and with your workaround about this issue (probably a bug of PS as you said) you have saved me a lot of time!! I encourage Prestashop to hire you you to update their Development documentation Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 17, 2013 Share Posted September 17, 2013 Hi, and thank you! Uhm... I think I'm missing a point what do you mean? After all it's just about getting the product id Or....I'm missing the point as always If you want to create the new field when creating a new product you must use the hookActionProductAdd (the hookActionProductUpdate is triggered when updating). So maybe it's interesting call the hookActionProductUpdate inside the hookActionProductAdd. Then when creating a new product the Tools::getValue('id_product'); will return 0 so you can use $id_product = $params['product']->id; which works in the update and in the add as well Link to comment Share on other sites More sharing options...
NemoPS Posted September 17, 2013 Author Share Posted September 17, 2013 Awwww right, true, yeah i thought that people wouldn't update a new tab as soon as they create a product, that's why I didn't add it but it's a nice suggestion, you can add it as a comment to the tut so other people can see it as well Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 17, 2013 Share Posted September 17, 2013 Awwww right, true, yeah i thought that people wouldn't update a new tab as soon as they create a product, that's why I didn't add it but it's a nice suggestion, you can add it as a comment to the tut so other people can see it as well Yes, that's a very small issue that in general will be invisible. Practically anybody creates a product at one step (when you have the wonderful save and stay button so close ). I'll add the comment in the tut. Regards Link to comment Share on other sites More sharing options...
Enrique Gómez Posted September 18, 2013 Share Posted September 18, 2013 I'm working on a tab module and as well as in your example I need custom javascript for my tab. So as you have indicated in the tut, you need to know when your tab has been loaded via the asynchronous loading that PS has implemented for the product page. So with the following js it works for the first time, but when you hit save and stay button in the new tab the code it's not fired when the page has been reloaded... . If you press the button in the others tab it's fired. $("#product-tab-content-ModuleNewfieldstut").on('loaded', function(){ //Code fired when the tab has been loaded displayFlags(languages, id_language, allowEmployeeFormLang); }) I've put my js directly in the footer of the new tab tpl and it works, but it's really strange so I've been digging and when you hit save and stay the normal post is used to load the current page with the current tab and there's no need to load the current tab asynchronous so it's not loaded via ajax nor the loaded event is fired by prestashop javascript. So it's seems that you have to take into account that sometimes you can use the ready event (as usual) and in the great major of cases it will be loaded with ajax so the loaded event must be used. It would be great if Prestashop would take into account this and fire the loaded event for the current tab if loaded without ajax Link to comment Share on other sites More sharing options...
El Patron Posted September 18, 2013 Share Posted September 18, 2013 Fabio! You rock...I will be taking this lesson today! Thanks for so much sharing.... Fred Link to comment Share on other sites More sharing options...
NemoPS Posted September 18, 2013 Author Share Posted September 18, 2013 Thanks Fred 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