lince Posted September 12, 2018 Share Posted September 12, 2018 Hello, I have a php script that resizes imagenes and I would like to convert this script into a module to be able to install it in prestashop. The idea would be to execute this code every time an image is added to a product. I can code php but I have never created a prestashop module. Can anybody provide some advise on how I could create this module ? Thank you. Link to comment Share on other sites More sharing options...
Rolige Posted September 12, 2018 Share Posted September 12, 2018 I think you can start by reading the official documentation: http://doc.prestashop.com/display/PS16/Creating+a+first+module http://doc.prestashop.com/display/PS17/Creating+a+PrestaShop+1.7+Module Link to comment Share on other sites More sharing options...
joseantgv Posted September 12, 2018 Share Posted September 12, 2018 2 hours ago, lince said: Hello, I have a php script that resizes imagenes and I would like to convert this script into a module to be able to install it in prestashop. The idea would be to execute this code every time an image is added to a product. I can code php but I have never created a prestashop module. Can anybody provide some advise on how I could create this module ? Thank you. Which is the different between your script/module and the native resizing function? Link to comment Share on other sites More sharing options...
lince Posted September 12, 2018 Author Share Posted September 12, 2018 1 hour ago, Rolige said: I think you can start by reading the official documentation: http://doc.prestashop.com/display/PS16/Creating+a+first+module http://doc.prestashop.com/display/PS17/Creating+a+PrestaShop+1.7+Module I have checked the docs but there is only information on how to install and configure. After that, how can I attach my code to prestashop so it is executed every time an image is uploaded ? 38 minutes ago, joseantgv said: Which is the different between your script/module and the native resizing function? Native function adds white borders, mine does not. Link to comment Share on other sites More sharing options...
Rolige Posted September 12, 2018 Share Posted September 12, 2018 You need works with hooks, PS use 2 hooks in this, actionOnImageResizeAfter and actionOnImageCutAfter Link to comment Share on other sites More sharing options...
joseantgv Posted September 13, 2018 Share Posted September 13, 2018 16 hours ago, lince said: Native function adds white borders, mine does not. Nice Link to comment Share on other sites More sharing options...
lince Posted September 14, 2018 Author Share Posted September 14, 2018 On 9/12/2018 at 5:59 PM, Rolige said: You need works with hooks, PS use 2 hooks in this, actionOnImageResizeAfter and actionOnImageCutAfter Thank you for the information. I have looked for hooks in the database and ps1.6 only has this hook defined in the database: actionObjectImageAddAfter So I checked the classes to see which one is using this hook but none of them is calling it. In ps 1.7 I was not able to find a single hook with the string "image" in the name. Also, the issue is that I need to resize the picture before PS does because if I do it after, I would get the image already resized with white borders instead of the original image. So I was thinking that maybe the only option would be to verride the function resize from the class ImageManager in order to place my functions instead. Do you think this would be the correct way to do it ? Thanks. 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