Giter VIP home page Giter VIP logo

eavcleaner's Introduction

EAV Cleaner Magerun Addon

Purpose of this project is to check for different flaws that can occur due to EAV and provide cleanup functions.

Use --dry-run to check result without modifying data.

Magento 1 or Magento 2?

The Magento 1 version is in this repository, the Magento 2 version is in another repository.

Commands

  • eav:check:models Check if the assigned sourcemodel, backendmodel and frontendmodel still exist and if they are allowed to be used.
  • eav:clean:product-attribute-set-values Check for abandoned attribute values in eav tables. The attribute was removed from an attribute set the values still exist.
  • eav:clean:scope-values Check for wrong scopes. Values in Scopes which shouldn't be present. For example values on Storeview level but attribute scope is global.
  • eav:clean:removed-store-view-values Remove attribute values for storeviews that don't exist anymore.
  • eav:clean:entity-type-values Remove attribute values with wrong entity_type_id. For example the table catalog_product_entity_int should only contain entries with entity_type_id == 10.
  • eav:clean:attributes-and-values-without-parent Remove catalog_eav_attribute and attribute values which are missing parent entry in eav_attribute. This can happen after importing data with foreign key check switched off.
  • eav:config:restore-use-default-value Check if config admin value and storeview value are the same, so "use default" doesn't work anymore. Delete the storeview values.
  • eav:attributes:restore-use-default-value Check if product attribute admin value and storeview value are the same, so "use default" doesn't work anymore. Delete the storeview values.
  • eav:attributes:remove-unused Remove attributes with no values set in products and attributes that are not present in any attribute sets.
  • eav:media:remove-unused Remove unused product images.

Ideas

See issues labeled enhancement

Installation

See the magerun addon installation guide

Contributors

  • Benno Lippert
  • Damian Luszczymak
  • Joke Puts
  • Peter Jaap Blaakmeer
  • Ralf Siepker

eavcleaner's People

Contributors

bennolippert avatar caprico85 avatar daim2k5 avatar dzschille avatar gpaddis avatar jhoelzl avatar jokeputs avatar matthiashofele avatar peterjaap avatar pixelhed avatar riversy avatar seansan avatar sprankhub avatar syhe avatar tmotyl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eavcleaner's Issues

Working op magento 2.2.5?

Is this module working still on Working op magento 2.2.5 open source?

Is the development ended on this module or will it be updated in the future?

Best regards

Move logic into models

It would be nice if the actual logic would be moved to models or helpers so it could be reused elsewhere. In my case I would like to call it after a custom importer has run. But since commands cannot be called directly there is no way except to copy the code.

How to install?

Sorry for the hassle but uploading this to the app/code directory and running the upgrade sequence doesn't seem to install the module.
Also composer require hackathon/eavcleaner-m2 doesn't seem to install.

Thanks in advance for anyone that can help me out how to get this installed on my dev environment.

Working on M2.2.1 RC ?

Hello,
Please can you tell me if your extension work with last Magento RC version 2.2.1 ?
thanks a lot to share your work with us.

Zend_Db_Statement_Exception with eav:clean:product-attribute-set-values

After running the eav:clean:product-attribute-set-values command I got this error.

$ magerun eav:clean:product-attribute-set-values
Start Cleaning Eav Values



  [Zend_Db_Statement_Exception]                                                                                                            
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your  
   MySQL server version for the right syntax to use near ',71,74,96,208,224,201,102,80,75)                                                 
                                      AND attribu' at line 3, query was: DELETE FROM `catalog_product_entity_varchar`                      
                                  WHERE `entity_id` = 43581                                                                                
                                      AND attribute_id NOT IN (,,71,74,96,208,224,201,102,80,75)                                           
                                      AND attribute_id IN (196,190,209,223,188,189,160,132,201,184,164,79,162,156,155,213,157,148,174,172  
  ,173,163,153,149,187,151,186,144,168,167,159,197,166,204,224,208,161,145,165,150,177,207,205,133,134,135,136,198,206,138,139,146,212,14  
  0,141,147,142,143,152,169) 

These were the two attributes with empty IDs in the IN condition

array(5) {
  'attribute_id' =>
  NULL
  'code' =>
  string(10) "created_at"
  'type' =>
  NULL
  'required' =>
  NULL
  'scope' =>
  string(6) "global"
}
array(5) {
  'attribute_id' =>
  NULL
  'code' =>
  string(10) "updated_at"
  'type' =>
  NULL
  'required' =>
  NULL
  'scope' =>
  string(6) "global"
}

How do I uninstall this extension?

Hiya. I'm struggling to uninstall this extension.

I've removed the folder fromm app/code
I've removed the entry from setup_module table
I've removed entry from config.php

but still whenever i run setup:upgrade i get this

PHP Fatal error: Uncaught Error: Class 'Hackathon\EAVCleaner\Console\Command\RestoreUseDefaultValueCommand' not found in /httpdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:116

I've searched the whole database and can't find anymore Hackathon entries, pls help

Dont understand what this does

Dont understand what this does

Is it possible from someon knowledgeable to elaborate a little more or provide an example in the readme

eav:config:restore-use-default-value Check if config admin value and storeview value are the same, so "use default" doesn't work anymore. Delete the storeview values.

eav:attributes:restore-use-default-value Check if product attribute admin value and storeview value are the same, so "use default" doesn't work anymore. Delete the storeview values.

Prefix missed? in magerun eav:clean:scope-values

Table prefix missed? The following commands dont work on our server because the tables do not exist. I think the error comes from the fact that it does not first check for a table prefix to set-up the table name

  • magerun eav:clean:scope-values
  • also for magerun eav:restore-use-default-value
  • eav:clean:removed-store-view-values
  • eav:clean:attributes-and-values-without-parent
  • eav:clean:entity-type-values

[Zend_Db_Statement_Exception] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.c atalog_product_entity_varchar' doesn't exist
table should be (in our case with prefix)

Table 'database.sof_c atalog_product_entity_varchar'

notice the sof

Not found table helper in Magento 2.3.1

$this->getHelper('table') throws the LogicException about not found helper near 87 line in EAVCleaner/Console/Command/RemoveUnusedMediaCommand.php.

Possible solution to change the next code:

$this->getHelper('table')
            ->setHeaders($headers)
            ->setRows($table)->render($output);

with

(new \Symfony\Component\Console\Helper\Table($output))
		    ->setHeaders($headers)
            ->setRows($table)->render();

Do we want to clear NULL values?

Start Cleaning Eav Values
We fix your Database 10320 Rows :-) Done!
Clean up 0 rows in catalog_product_entity_varchar
Clean up 48633 rows in catalog_product_entity_int
Clean up 6741 rows in catalog_product_entity_decimal
Clean up 3246 rows in catalog_product_entity_text
Clean up 447 rows in catalog_product_entity_datetime
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
Deleting NULL value 0
... etc

Is this something we want? Couldn't we just skip deleting the NULL values?

Is "sourcemodel eav/entity_attribute_source_boolean not allowed for frontend input type: boolean" a valid EAV model check issue?

I'm hit with this error:

sourcemodel eav/entity_attribute_source_boolean not allowed for frontend input type: boolean - the frontend input type should be select

Triggered by:

if ($sourceModel != '' && ! in_array($attribute->getFrontendInput(), $sourceModelsAllowed)) {
    $additionalMessage = null;
    if($attribute->getSourceModel() == 'eav/entity_attribute_source_boolean' && $attribute->getFrontendInput() != 'select') {
        $additionalMessage = ' - the frontend input type should be select';
    }
    $error .= '<error>sourcemodel ' . $attribute->getSourceModel() . ' not allowed for frontend input type: ' . $attribute->getFrontendInput() . $additionalMessage . '</error>';
}

However, this error applies to any boolean attribute created by vanilla Magento 1.9 / OpenMage 19. Also it seems to functionally work fine. Are we sure this is an actual problem?

Restore Use Default Value not actually working

Looks like the sql is incorrectly referencing entity_id in the catalog_product_entity_* tables when it should be referencing row_id:

--- 
+++ 
@@ -59,14 +59,14 @@
             $rows = $db->fetchAll('SELECT * FROM ' . $fullTableName . ' WHERE store_id != 0');
 
             foreach ($rows as $row) {
                 // Select the global value if it's the same as the non-global value
                 $results = $db->fetchAll(
                     'SELECT * FROM ' . $fullTableName
-                    . ' WHERE attribute_id = ? AND store_id = ? AND entity_id = ? AND value = ?',
-                    array($row['attribute_id'], 0, $row['entity_id'], $row['value'])
+                    . ' WHERE attribute_id = ? AND store_id = ? AND row_id = ? AND value = ?',
+                    array($row['attribute_id'], 0, $row['row_id'], $row['value'])
                 );
 
                 if (count($results) > 0) {
                     foreach ($results as $result) {
                         if (!$isDryRun) {
                             // Remove the non-global value

Error? or just warning? sourcemodel eav/entity_attribute_source_boolean not allowed for frontend-type: boolean

Error? or just warning? sourcemodel eav/entity_attribute_source_boolean not allowed for frontend-type: boolean


 magerun eav:check:models
+----------------+--------------+-----------------+-------------------------+----------------------------------------------------------------------------------------+
| attribute_code | attribute_id | entity_type     | label                   | error                                                                                  |
+----------------+--------------+-----------------+-------------------------+----------------------------------------------------------------------------------------+
| skip_feed      | 203          | catalog_product | Skip from products feed | sourcemodel eav/entity_attribute_source_boolean not allowed for frontend-type: boolean |
+----------------+--------------+-----------------+-------------------------+----------------------------------------------------------------------------------------+


Support for PHP 7.2

Magento 2.3 uses PHP 7.2. Is there something else to do apart from updating the composer.json to add php7.2.*?

Add support for prefixed tables in Magento 2.3.1?

When trying to use php bin/magento eav:media:remove-unused I see the next error: Base table or view not found: 1146 Table 'store.catalog_product_entity_media_gallery' doesn't exist, query was: SELECT value FROM catalog_product_entity_media_gallery WHERE value = ?.

There are no commands defined in the "eav:media" namespace.

Hi, Ive been disappointed.
readme file no showing composer installation.. even not giving clear information for supported php and magento versions...

Copy paste EAVcleaner under app/code... and what is further commands? Why you dont show exact installation path step by step?
we dont run bin/magento setup:upgrade, or bin/magento setup:di:compile or bin/magento setup:static-content:deploy ??
which one we have to use?
I could not be successfull installing the extension since there's no clear path given for installation.
Weird situation as we know you are experts on magento2

please make clear the installation process.
looking forward to hearing from you soon.

Savas

Idea; remove unused attributes

Remove attributes that have no values set in products, and remove attributes that exist but are not present in any attributesets.

Using crontabs for periodic cleanup of unused media

Hi, absolute beginner here. I've been messing around with the EAVCleaner and testing its functionality, so far I've found that the module is a nice fit for what we intend to use the module for. I have a question, however (pardon me if this isn't the right place to ask).

I've been looking to run certain commands to periodically clean up unused media, so specifically: I'd like to run the bin/magento eav:media:remove-unused on a weekly basis so a sprawl of unused media doesn't spiral out of control.

I've tried adding the command to the crontab but so far I've been stumped and not getting it to work locally. I was curious if such a functionality has been created before (specifically for the EAVCleaner) and/or if somebody is able to point me in the right direction.

eav:media:remove-unused: Do Not Remove Custom Placeholder Images

If I see correctly, custom placeholder images defined in one of these settings

  • catalog/placeholder/image_placeholder
  • catalog/placeholder/menu_image_placeholder
  • catalog/placeholder/small_image_placeholder
  • catalog/placeholder/thumbnail_placeholder

are stored in the directory /media/catalog/product/placeholder/default. The command eav:media:remove-unused removes these images. I think images in this directory should be skipped and should not be removed. They are not referenced in the database, but are still used.

Working on M2 V2.1.7

Wondering if this works on Magento 2.1.7.
We copied the files to the app/code/EAVCleaner folder but magento does not show the module.

Thanks!

Syntax error in SQL syntax

I get this error message:

    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM catalog_eav_attribute WHERE `attribute_id ` not in(SELECT `attribute_id` F' at line 1

Fixed in #20.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.