1

I have created one custom module where user(customer) can upload and edit his own product through frontend( my account ) dashboard. In this I have used code to edit the image and set it to thumbnail, base, and image for uploaded product. But it was not updating the Image. So Later on I tried to change through admin dashboard. Even after setting up thumbnail, small_image and and image but now it is not upating the product image for any product through admin dashboard(backend).

I have used the code

if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
if (!$product->hasThumbnail()) $product->setThumbnail(Mage::helper('catalog/image')->init($product, 'thumbnail'));

I dont know where should check for the error as it is not showing error on admin dashboard as well. I have checked the database for product_entity table and for gallery and it is showing the image.

2

Have you called $product->save() method after below code?

if (!$product->hasSmallImage())
   $product->setSmallImage($product->getImage());
if (!$product->hasThumbnail()) 
   $product->setThumbnail(Mage::helper('catalog/image')->init($product, array('thumbnail','small_image','image'))); 

Update:: set the Small Image, Thumbnail and image.

  • Yes, after saving got another issue with this code now unable to update the image through dashboard.. it is not setting up as thumbnail small image and base image .. :( – MagentoBoy Jan 24 '14 at 12:07
  • I have Update the Code. – Keyul Shah Jan 24 '14 at 12:14
  • @MagentoBoy are any errors presented? Or does it just refuse to save at all? – Dave Dec 15 '14 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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