Setting image upload path dynamically #17126
Replies: 3 comments
-
Did you take a look at: https://pimcore.com/docs/platform/Pimcore/Extending_Pimcore/Event_API_and_Event_Manager/#asset-upload-path |
Beta Was this translation helpful? Give feedback.
-
Recently, we achieved dynamic asset folder creation and asset renaming based on our custom logic using the DataObjectEvent in Pimcore. We structured the asset hierarchy in our application around brand, category, and subcategory, creating folders accordingly. Images are named as follows: Thumbnail Image Upload: When uploading a thumbnail, the image is named {ProductSKU}_T.ImageExtension (e.g., GSM_T.jpg). Please configure the /config/services.yaml file and create the AssetRenameListener.php file as shown in the sample below. services: namespace App\EventListener; use Pimcore\Event\Model\DataObjectEvent; class AssetRenameListener implements EventSubscriberInterface
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing the detail in the documentation, and also for sample code. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Trying to migrate to PIMCore from google sheets for product and related asset management, working on a proof-of-concept, before decision on going enterprise.
I have an image component in my Product class. I want each image to be uploaded to a specific folder for that instance of Product (a path using product->productCode). Also, I need to see those uploaded images in Assets and also in my current cloud storage solution, which Pimcore uploaded files folder will be synced.
Currently, I failed to set a custom upload path for each Product. I added event listener for preAdd and preUpdate, I tried setUploadPath, setCustomUploadPath, setPath on product->picture (name of my image component), all failed with no such method.
So, question is, is it possible to set an upload path for each object of my Product class?
Beta Was this translation helpful? Give feedback.
All reactions