1.0.8.20 - images directory
-
PiLLaO
- Contributor
- Posts: 107
- Joined: Thu Nov 05, 2020 9:28 pm
- Phoenix Version: v1.1.0.6
- Has thanked: 53 times
- Been thanked: 11 times
1.0.8.20 - images directory
Hi!
I'm using v1.0.8.20
I need to choose the directory to upload images (separated by manufacturer).
I just make a file in catalog/admin/includes/hooks/admin/catalog/ to add the input to choose the folder, but I don't know where create the file to change the image path.
I look that this file catalog/admin/includes/actions/catalog/update_product.php save the product data to DB
Need to override this file?
Is there a better way to do this?
Thanks in advance.
I'm using v1.0.8.20
I need to choose the directory to upload images (separated by manufacturer).
I just make a file in catalog/admin/includes/hooks/admin/catalog/ to add the input to choose the folder, but I don't know where create the file to change the image path.
I look that this file catalog/admin/includes/actions/catalog/update_product.php save the product data to DB
Need to override this file?
Is there a better way to do this?
Thanks in advance.
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: 1.0.8.20 - images directory
Admin actions can't be overridden and as far as I see there is no hook which allows to manipulate the image path and database entry.
I believe you would need to use a copy of that action and call it in a copy of the views/new_product.php file.
Maybe best a custom catalog.php file to which you redirect in a hook. Then you can use there your custom view and action file.
I believe you would need to use a copy of that action and call it in a copy of the views/new_product.php file.
Maybe best a custom catalog.php file to which you redirect in a hook. Then you can use there your custom view and action file.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
- zipurman
- Builder
- Posts: 540
- Joined: Tue Oct 13, 2020 5:20 pm
- Phoenix Version: v
- Has thanked: 93 times
- Been thanked: 162 times
Re: 1.0.8.20 - images directory
You could just write an admin hook to listen_postAction and then update the image as required as your custom field should be in the $_POST. The original update that catalog/admin/includes/actions/catalog/update_product.php does, would be done first, and then listen_postAction would allow you to update again, but with the desired image path data?
zipurman
-----------
-----------
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: 1.0.8.20 - images directory
But the image file would still be saved in the original location “images/“. Or do I miss something?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
- zipurman
- Builder
- Posts: 540
- Joined: Tue Oct 13, 2020 5:20 pm
- Phoenix Version: v
- Has thanked: 93 times
- Been thanked: 162 times
Re: 1.0.8.20 - images directory
BTW, the following addon has this functionality and more.
app.php/addons/paid_addon/zipur_product_manager
app.php/addons/paid_addon/zipur_product_manager
zipurman
-----------
-----------
-
raiwa
- Certified Developer
- Posts: 1640
- Joined: Sat Dec 21, 2019 8:08 am
- Phoenix Version: 1.1.0.6
- : Buy Me A Beverage
- Has thanked: 70 times
- Been thanked: 152 times
Re: 1.0.8.20 - images directory
Thinking more about the original question and my first answer:
You could rename the action in a redirect hook from "update_product" to "custom_update_product" and then use a copy of the action file with your modifications. This would be the most similar to override the action.
Preston's method may be less core invasive and therefore more stable regarding core updates.
You could rename the action in a redirect hook from "update_product" to "custom_update_product" and then use a copy of the action file with your modifications. This would be the most similar to override the action.
Preston's method may be less core invasive and therefore more stable regarding core updates.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
https://docs.google.com/spreadsheets/d/ ... sp=sharing
Need Help?viewtopic.php?f=10&t=27
-
14Steve14
- Senior Contributor
- Posts: 923
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: 1.0.8.20 - images directory
No idea whether it was ever released as an addon though.14Steve14 wrote: ↑Sun Jul 30, 2023 11:08 am Is this the sort of thing you are after.
viewtopic.php?p=12310#p12310
-
PiLLaO
- Contributor
- Posts: 107
- Joined: Thu Nov 05, 2020 9:28 pm
- Phoenix Version: v1.1.0.6
- Has thanked: 53 times
- Been thanked: 11 times
Re: 1.0.8.20 - images directory
How can I know the products listener? Because if I search in files for listen_postAction I can't find anything.zipurman wrote: ↑Sat Jul 29, 2023 4:28 am You could just write an admin hook to listen_postAction and then update the image as required as your custom field should be in the $_POST. The original update that catalog/admin/includes/actions/catalog/update_product.php does, would be done first, and then listen_postAction would allow you to update again, but with the desired image path data?
I'm having problems to make It works, and I see that I don't know where need to put the code to make it works (listener are new for my).
The easyest way, will be modify the path here (set_destination)
Code: Select all
$products_image = new upload('products_image');
$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($products_image->parse() && $products_image->save()) {
$sql_data['products_image'] = Text::prepare($products_image->filename);
}