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


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)

2 Answers 2


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.


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).



  • No,No need to upload / move the image, i want to update the database only.directly, I am inserting products using this inchoo.net/magento/programming-magento/…, the problem is that i want to upload the image path only as i have not the image,Because the image will be display from other server Nov 28, 2014 at 9:22
  • Oh ok,This link will help you. Nov 28, 2014 at 9:26
  • This is for Magento Go Nov 28, 2014 at 9:32
  • Sorry , is there any another way to solve this? Nov 28, 2014 at 10:53

The images are stored in the table catalog_product_entity_media_gallery (for gallery) and in catalog_product_entity_varchar (for image, small image and thumbnauil)

You can change them using direct db queries like this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.