Magento – How to we add/update a image path with own code without using addImageToMediaGallery()

imagemagento-1.8PHPproduct-images

Can we update a own defined product image path to database, I am adding products with own custom code.I want to add image database without help of

->addImageToMediaGallery()

Is it doable??
without using this line i want to add direct path // external url to database

# media gallery initialization
->setMediaGallery(array('images' => array (), 'values' => array ())) 
# assigning image, thumb and small image to media gallery
->addImageToMediaGallery('xxx/my.jpg', array('image', 'thumbnail', 'small_image'), false, false)

Best Answer

Magento keep images path in media/catalog/product/ then if your image name is 'sampleimage.jpg' then magento creates a directory name taken as the first and second letter from the image name then create like below.

media/catalog/product/s/a/sampleimage.jpg

So, if you want to change the magento images path, this will lead you to change core functionality.Changing core functionality for this purpose is not advisable from me.

Edit: for your question,

you can add own path, then if you use addImageToMediaGallery($file,$mediaAttribute = null,$move = false,$exclude = true) method for saving image, the $move parameter is the exact one you need to change for your problem.

if it is true then it move the image from the file path you have given.
if it is false then it copies the image.(so image remains in filepath).

Edit:

This QUESTION WILL HELP YOU.

Related Topic