I have used the below command in Magento CLI,

php bin/magento catalog:product:attributes:clean

I read the description for this command in forums and stack overflow, they only say Removes unused product attributes but I need an example for a real-time process. Because it did not affect any product attributes.


Enter the following command : php bin/magento, you will see all the commands with theire description

enter image description here

php bin/magento catalog:product:attributes:cleanup => Removes unused product attributes.

See : vendor\magento\module-catalog\Console\Command\ProductAttributesCleanUp.php::execute()

protected function execute(InputInterface $input, OutputInterface $output)
        $connection = $this->attributeResource->getConnection();
        $attributeTables = $this->getAttributeTables();

        $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, count($attributeTables));
        $progress->setFormat('<comment>%message%</comment> %current%/%max% [%bar%] %percent:3s%% %elapsed%');

        try {
            // Find and remove unused attributes
            foreach ($attributeTables as $attributeTable) {
                $progress->setMessage($attributeTable . ' ');
                $affectedIds = $this->getAffectedAttributeIds($connection, $attributeTable);
                if (count($affectedIds) > 0) {
                    $connection->delete($attributeTable, ['value_id in (?)' => $affectedIds]);

            $output->writeln("<info>Unused product attributes successfully cleaned up:</info>");
            $output->writeln("<comment>  " . implode("\n  ", $attributeTables) . "</comment>");
            return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
        } catch (\Exception $exception) {

            // we must have an exit code higher than zero to indicate something was wrong
            return \Magento\Framework\Console\Cli::RETURN_FAILURE;
  • 1
    Yea, we can all see what it says it does, but what does it actually.... because it looks like it does nothing. Mar 7 '20 at 23:36

When removing a store to a product. The data of that product store view are not deleted in these tables. I'm not yet sure why.

  • catalog_product_entity_varchar
  • catalog_product_entity_text
  • catalog_product_entity_decimal
  • catalog_product_entity_datetime
  • catalog_product_entity_int

You may encounter issues like when filtering in product grid.

In our case. set filter status = 'Enabled'. but you will see some rows that have status = 'disabled'. the reason is, it is enabled to the store you deleted which needs to be cleanup. "Magento 2.3.4"

This is where this command comes in:

php bin/magento catalog:product:attributes:clean

This will clean the tables. So that grid filter will work as expected.

I think grid filter will not only be the issue, I hope this gives some idea.

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.