quentinvillanova Posted July 19, 2022 Share Posted July 19, 2022 Hi, I have an issue with some images as mention in that post: In the continuity of this issue, I'm searching were are images managed in Prestachop code. I mean, in what function images are processed and stored in folders img/p/... Can someone help me ? Thanks. Link to comment Share on other sites More sharing options...
Ali Samie Posted July 19, 2022 Share Posted July 19, 2022 You should investigate through the import process. Anyway, the core for import is in this path: src/Adapter/ImportProductImportHandler.php And the main method is importRow Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 19, 2022 Author Share Posted July 19, 2022 (edited) I've take a look and it not seems to be what I'm searching for. In the function you told me there is no "image" variable or something like that. I set some breakpoint and when I try to create a product with an image nothing break. But thanks for your help. Edit: But I find something interesting in AdminProductDataProvider.php file. Edited July 19, 2022 by quentinvillanova (see edit history) Link to comment Share on other sites More sharing options...
Ali Samie Posted July 19, 2022 Share Posted July 19, 2022 1 hour ago, quentinvillanova said: I've take a look and it not seems to be what I'm searching for. In the function you told my there is no "image" variable or something like that. I set some breakpoint and when I try to create a product with an image nothing break. But thanks for your help. Edit: But I find something interesting in AdminProductDataProvider.php file. Actually every thing happens in that file. Just take a look at this method saveProductImages in this file src/Adapter/ImportProductImportHandler.php Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 19, 2022 Author Share Posted July 19, 2022 Ok, I'll take a look this afternoon. Thanks. Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 19, 2022 Author Share Posted July 19, 2022 (edited) I don't understand, the saveProductImages seems to be what I'm searching for. But I put breakpoint in it and nothing happens, I create a new product in Back-Office and it should break where I want but the page refresh nomally. I know that my debugger work fine so it's not the problem. So create a product work, I can see it in Front-Office, but it looks like it never pass through the function. I'm a bit desperate actually. Edited July 19, 2022 by quentinvillanova (see edit history) Link to comment Share on other sites More sharing options...
Ali Samie Posted July 19, 2022 Share Posted July 19, 2022 I think importing a product is totally different from creating a new one. Please verify you are importing at first. And then ensure you are using prestashop import controller in BO. If you are using a module to do the import it might not go through that exact file and they might have copied the file to their module and then every thing about the import happens there. Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 19, 2022 Author Share Posted July 19, 2022 Maybe I missword a bit. I want to know what function is executed when I create a product from Back-Office, I mean from Catalog>Products>Add Product. Link to comment Share on other sites More sharing options...
Ali Samie Posted July 19, 2022 Share Posted July 19, 2022 I enabled debug mode and found the backoffice controller This is the controller: "src/PrestaShopBundle/Controller/Admin/ProductController.php" Then I searched through that file. I got to this part "$form->isSubmitted()" and some lines after this part I found "$adminProductController->setAction('save'); ". This means the products is saved in "controllers/admin/AdminProductsController.php" Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 19, 2022 Author Share Posted July 19, 2022 Thank you so much to put that much effort to help me ! I'm so dumb, why didn't I look at this earlier ?! I'll study this controller more in detail and come back too you later. Thanks. Link to comment Share on other sites More sharing options...
quentinvillanova Posted July 20, 2022 Author Share Posted July 20, 2022 (edited) Hi, So actually, I found that image path is generated right when I drop or select an image in the image field, so before I save the product. Tell me if I'm wrong but I think this part is manage in a js file ? So if I really understand, the path is generate from a sort of id which depends on the last one registered. I learnt a lot of things but i think it's too far from what I'm searching for at the beginning explained in that post : Thanks a lot for your help. Edited July 20, 2022 by quentinvillanova (see edit history) Link to comment Share on other sites More sharing options...
Ali Samie Posted July 20, 2022 Share Posted July 20, 2022 Thats kind of right. I have not digged into this before, but i have searched for the import of product, that does not get any files as input, it gets a series of URLs, downloads them in a temp path and then, it creates a folder based on the id_image and then save the original and resized versions of that image. For example if id_image is 1234, then it will go to this path, img/p/1/2/3/4/image.jpg 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