1

I am try to delete duplicate images using this source link

enter image description here

1

It looks like you have some file permission issues, probably on the dup.php file put possibly on the image files too, i'd recommend resetting file permissions then giving it another shot.

You can do this via the command line with the following:

find . -type f -exec chmod 400 {} \;
find . -type d -exec chmod 500 {} \; 
find var/ -type f -exec chmod 600 {} \; 
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \; 
find media/ -type d -exec chmod 700 {} \;
chmod 700 includes
chmod 600 includes/config.php

Source: http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html

2
  • i am new to magento, could you pls explain briefly.
    – Gem
    Jun 28 '16 at 12:37
  • The error you have is saying permission denied when trying to access a file, the php script is probably fine but there is a common issue with the uploader that causes images to be uploaded with the wrong file permissions (Making them inaccessible) If you run those commands it will update any files and folders that may have invalid permissions. All you have to do is ssh into your local server, navigate to the root of magento and copy those commands into your terminal window.
    – DanCarlyon
    Jun 28 '16 at 12:43
1

Your code is trying to retrieve a file that does not exists:

file_get_contents(C:\wamp\www\giri\media\catalog\product);

This is the line trigerring the exception.

Your custom code probably loops through images and tries to import an image that is not set or empty.

To solve it you need to modify the code from the link you posted and add some checks.

Replace:

$filepath =  Mage::getBaseDir('media') .'/catalog/product' . $base_image  ;
if(file_exists($filepath))
    $_md5_values[] = md5(file_get_contents($filepath));

With:

if ($base_image) {
    $filepath =  Mage::getBaseDir('media') .'/catalog/product' . $base_image  ;
    if(file_exists($filepath))
        $_md5_values[] = md5(file_get_contents($filepath));
}

And replace:

        $filepath =  Mage::getBaseDir('media') .'/catalog/product' . $_image->getFile()  ;
        if(file_exists($filepath))
            $md5 = md5(file_get_contents($filepath));
        else
            continue;

        if(in_array($md5, $_md5_values))
        {
            $mediaApi->remove($_product->getId(),  $_image->getFile());
            echo "rn removed duplicate image from ".$_product->getSku();
            $count++;
        } else {
            $_md5_values[] = $md5;
        }

With:

 if ($image->getFile()) {
        $filepath =  Mage::getBaseDir('media') .'/catalog/product' . $_image->getFile()  ;
        if(file_exists($filepath))
            $md5 = md5(file_get_contents($filepath));
        else
            continue;

        if(in_array($md5, $_md5_values))
        {
            $mediaApi->remove($_product->getId(),  $_image->getFile());
            echo "rn removed duplicate image from ".$_product->getSku();
            $count++;
        } else {
            $_md5_values[] = $md5;
        }
}
2

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.