0

i sell products that come in variations. i upload image into media/import, and after the 1st product on csv file, magento create duplicate image file and renames it like below for the other products that have same image filename as 1st product on csv. i have products that come in 60-70 variations, so this is filling storage qquickly, how can i fix this?

enter image description here

2 Answers 2

3

By default Magento added this check as if same file exist then rename it because there may be possibility admin can upload different image with same name.

So as your requirement you need to do some code level change:

Step1: Copy file

app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php

to your local code pool as

app/code/local/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php

Step2: search for function uploadAction() & find line $uploader->setAllowRenameFiles(true); & then change to $uploader->setAllowRenameFiles(false);

Now try uploading csv now. It should work.

1
  • akhil, i dont do coding man. have to look for someone to do this for me, can you recommend?
    – joxnard805
    Commented Jan 21, 2017 at 4:58
0

To prevent the duplicate images in the Dataflow Profiles importer, I had to do the following:

Step 1

Copy the file:

/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php

to:

/app/code/local/Mage/Catalog/Model/Product/Attribute/Backend/Media.php

Step 2

Around line 268, inside the function addImage, find the following line:

$fileName = $this->_getNotDuplicatedFilename($fileName, $dispretionPath);

Replace this with:

if (Mage::app()->getRequest()->getControllerName() != 'system_convert_gui')
    $fileName = $this->_getNotDuplicatedFilename($fileName, $dispretionPath);

This will only modify the filename if we are running through anything else other than the dataflow profile importer.

Step 3

Around line 578, find the function _getUniqueFileNameand add the following at the start:

if (Mage::app()->getRequest()->getControllerName() == 'system_convert_gui')
    return $file;

This will prevent any checks for unique filenames.

After doing the above I can now import images through the (old) Dataflow Profiles and if the image filename already exists it will be overwritten. If I upload an image manually through the Magento admin and that filename already exists, it will rename it as it used to do.

If anyone knows a better cleaner way of doing this then please let me know!

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.