OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
871 stars 436 forks source link

Module Defcon2-Imaclean not working? #1475

Closed LuizSantos1 closed 3 years ago

LuizSantos1 commented 3 years ago

Summary (*)

I used to use a module called Defcon2-Imaclean, it would fix a native issue in Magento that were never fixed. The issue was: If you delete the product, the images of this deleted product, would remain and pile up increating weight of the site. What the module did? Created a option "Imaclean" in System/Imaclean When you click on it, it would give the options to "Update" and see the images of the deleted product, it would select them and remove it from Magento folders.

Examples (*)

Now, with OpenMage 1.9.4.11 it does not show any image, even if you delete a product My question is: Did OpenMage fix this issue and that's why the module does not work or there's a compability issue with OpenMage and the module?

Proposed solution

I wonder if it is a problem with the module or OpenMage has fixed the issue

Regards

addison74 commented 3 years ago

I am using a modified version of this extension. It is one of my favorite for years. My modifications are not changing the base code, just image sizes, columns sizes, English names, refresh button behavior (once it is pressed all records in the table in DB are deleted before filling up again).

I checked for you the default ImaClean + OpenMage 20.0.6 in a test environment Debian 10, Apache 2.4.38, PHP 7.3.19, MariaDB 10.3.27. No issues found. The version I used is downloaded from here: https://github.com/sreichel/magento-Defcon2-Imaclean.

sreichel commented 3 years ago

@ADDISON74 can you please make a PR with your changes? I'd update the package and make it available at packist.org. I'd also add a shell script (or maybe make a PR for n98-magerun).

addison74 commented 3 years ago

@sreichel: It won't be a problem. If I remember well we discussed in the past about this extension. I have to make a diff between the version you forked and the one I modified to understand what I changed. It's been a while since I analyzed this very useful extension. Over the years it helped me to clean the system file with tenth thousands of orphan files. But also helped to download a few product images for uploading them again.

LuizSantos1 commented 3 years ago

For now, I have managed to fix my issue using a script on the root installation https://gist.github.com/jeroenvermeulen/e1dc727bcaadeade14ea

I have created a php file at the root called: jv_clean_product_images.php as explained on the link above and typed: www.mydomain.com/jv_clean_product_images.php and hit enter. Sometimes I have to run it twice in order to clean the images.

fballiano commented 3 years ago

Is this an openmage issue or, if external, could be closed?

LuizSantos1 commented 3 years ago

@fballiano I do not really know. Well, I have reported that this extension has stopped working with OpenMage The solution was not given, so I started using a different solution mentioned above. I guess someone could investigate why this module has stopped working...

sreichel commented 3 years ago

@LuizSantos1 please close and raise an issue at my repo, if it does not work.

@ADDISON74 PR? ;)

addison74 commented 3 years ago

@sreichel: Sorry for my late reply. I left you a message in your repository related to an open issue we discussed about in the past. Except that issue which seems to be solved, after making a diff there are only a few changes I have made in plus comparing with your version. Here they are:

First Change /app/code/community/Defcon2/Imaclean/Block/Adminhtml/Imaclean/Grid.php

line 50 from

'caption' => Mage::helper('defcon2imaclean')->__('delete'),

to

'caption' => Mage::helper('defcon2imaclean')->__('Delete'),

Second Change /app/code/community/Defcon2/Imaclean/Block/Adminhtml/Imaclean.php

line 17 from

$this->_headerText = Mage::helper('defcon2imaclean')->__('Items Manager. These files are not in database.');

to

$this->_headerText = Mage::helper('defcon2imaclean')->__('Orphan Product Images');

Third Change /app/code/community/Defcon2/Imaclean/etc/adminhtml.xml

This is the new content of the file which moves ImaClean link to Tools menu.

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Defcon2_Imaclean
 *
 * @category   Defcon2
 * @package    Defcon2_Imaclean
 * @copyright  Copyright (c) 2016 Manuel Canepa (http://cv.manuelcanepa.com.ar/)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<config>
    <menu>
        <system>
        <children>
        <tools>
            <children>
                    <d2imaclean module="defcon2imaclean" translate="title">
                <title>ImaClean</title>
                <sort_order>2000</sort_order>
                <action>adminhtml/imaclean</action>
            </d2imaclean>
            </children>
        </tools>
        </children>
        </system>
    </menu>
    <acl>
    <resources>
            <admin>
                <children>
                    <system>
            <children>
                <tools>
                <children>
                                <d2imaclean>
                    <title>ImaClean</title>
                                </d2imaclean>
                </children>
                </tools>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>
addison74 commented 3 years ago

If it were up to me I would integrate this extension into OpenMage because it is extremely important. I recently used it in a store that had almost 42,000 orphan product images accumulated in the last 3 years with an average size of 400 kb. The store administrator did not know that they were stored up. I don't even want to imagine if he backed up periodically the system file and didn't use a program like rsync how much bandwidth he consumed unnecessarily.

@fballiano: I looked into your repository and I saw that you created a similar solution. I would appreciate if you test Defcon ImaClean and make a comparison with yours.

fballiano commented 3 years ago

@ADDISON74 I sincerely thought it was abandoned, and to create a new module is always a nice way of experimenting :-) also in my version I wanted to have category images cleaning (with multiple attributes read from the eav) and wysiwyg images too (not 100% completed at the moment).

LuizSantos1 commented 3 years ago

To the ones still with troubles with the Imaclean extension, download the improved vertion made by @sreichel from this link: https://github.com/sreichel/magento-Defcon2-Imaclean And apply the mods suggested by @ADDISON74 on the comment above. As mentioned, with the mods, Imaclean will be under: System/Tools/Imaclean This way I also think it stays more organized.

I have followed the mods steps and it is fully working now. The previous solution given by me is not good enough as it leaves some images behind.

As @ADDISON74 suggested, that would be great if #OpenMageTeam could integrate this extension as part of the system or leave it as "main extension feature" as it helps a lot with this Magento issue of leaving orphan images behind.

Thank you guys!

addison74 commented 3 years ago

And these are improvements:

1. It would be great if we have similar tool for cleaning the orphan images of the categories. We could start from the current form of ImaClean and insert a new column in the grid to differentiate between Product and Category, to filter the images.

2. Imaclean helped me finding images and download them via direct link, without having to connect to the server and take them from there. The current version could be improved by adding a link on Actions column bellow to Delete link for saving an image.

fballiano commented 3 years ago

@ADDISON74 https://github.com/fballiano/magento1-image-cleaner does categories and wysiwyg

addison74 commented 3 years ago

OK. I will check your version and we can continue the discussions there.

addison74 commented 3 years ago

After testing @fballiano extension I can say it is at least 50% faster than ImaClean in finding orphan product images. It also can find orphan category images.

There are still issues that need a fix and I reported them already. Probably I will switch to this extension from now on once it is in a great shape. If anyone is interested in discussions please visit: https://github.com/fballiano/magento1-image-cleaner.

sreichel commented 3 years ago

If this is a good working solution, i'll archive my fork and point to this module. Nice. :)