# 安装EAVCleaner清理未使用的产品图片.

**URL:** https://forum.magentochina.org/t/%E5%AE%89%E8%A3%85eavcleaner%E6%B8%85%E7%90%86%E6%9C%AA%E4%BD%BF%E7%94%A8%E7%9A%84%E4%BA%A7%E5%93%81%E5%9B%BE%E7%89%87/510
**Category:** Magento 2.X
**Tags:** 后端, 优化, 清理
**Created:** [2018 年11 月 25 日 09:18 UTC](https://forum.magentochina.org/t/%E5%AE%89%E8%A3%85eavcleaner%E6%B8%85%E7%90%86%E6%9C%AA%E4%BD%BF%E7%94%A8%E7%9A%84%E4%BA%A7%E5%93%81%E5%9B%BE%E7%89%87/510 "2018-11-25T09:18:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### 作者： ![Shuai](https://forum.magentochina.org/user_avatar/forum.magentochina.org/shuai/32/3_2.png) [@Shuai](https://forum.magentochina.org/u/Shuai)
#### 发布日期： [2018 年11 月 25 日 09:18 UTC](https://forum.magentochina.org/t/%E5%AE%89%E8%A3%85eavcleaner%E6%B8%85%E7%90%86%E6%9C%AA%E4%BD%BF%E7%94%A8%E7%9A%84%E4%BA%A7%E5%93%81%E5%9B%BE%E7%89%87/510/1 "2018-11-25T09:18:56Z")

</div>

手里有个站，图片已经有80G了，之前删了不少图片，估计有很多没有使用的，所以这里打算清理一下。  
 ![image](https://forum.magentochina.org/uploads/default/original/1X/bded204e1fae0ccb92daa0609d6114351834d43c.png)  
首先需要安装:

> **[GitHub - netz98/n98-magerun2: The swiss army knife for Magento developers,...](https://github.com/netz98/n98-magerun2)**
>
> The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a ...

然后再安装:

> **[GitHub - magento-hackathon/EAVCleaner: Clean up your Magento database by...](https://github.com/magento-hackathon/EAVCleaner)**
>
> Clean up your Magento database by removing orphaned, unused and wrongly added attribute, attribute values and settings (for M1) - GitHub - magento-hackathon/EAVCleaner: Clean up your Magento databa...

需要注意的是这两个插件都有相对的magento1和magento2的版本，需要安装对应版本。  
N98这里我们就不讨论了，这里我们说一下EAVCleaner的安装办法。

1. 我这里安装使用的是magento2的版本，所以我们首先先下载:

> wget [https://github.com/magento-hackathon/EAVCleaner/archive/magento2.zip](https://github.com/magento-hackathon/EAVCleaner/archive/magento2.zip)

1. 到你的Magento2根目录依次创建:

> app/code/Hackaton/EAVCleaner/

1. 解压缩第一步的文件，然后覆盖到app/code/Hackaton/EAVCleaner/目录

4.在Magento2根目录运行:bin/magento se:up

5.尝试再尝试运行bin/magento eav,看看是否有多出来的功能,像我这样就是对的:

 ![image](https://forum.magentochina.org/uploads/default/original/1X/7abf37781b6af1f5868a1abe2f822f78c3c87f39.png)

1. 从上图我们可以得知，清除未使用图片的命令是eav:media:remove-unused。

7.开始测试吧。  
 ![image](https://forum.magentochina.org/uploads/default/original/1X/fe1099323602a63755fe79add03b35395d8c8383.png)  
速度根据产品数量和图片数量来的，我有20K+ SKU，速度真的不敢恭维。不过总比没有好  
注意测试之前请备份。。。

最后跑完，发现并没有减少多少图片，看来还是要再找其他办法解决这个问题.  
 ![image](https://forum.magentochina.org/uploads/default/original/1X/2b6a74a3141871ebb06062276b9738d67825d6de.png)
