2

Go to Admin > System > Cache Management

I want to disable flush image cache button in backend given Which is highlighted in bellow image for security purpose.

Can anyone give me solution.

Thanks.

enter image description here

  • For all user or specific user – Amit Bera Mar 11 at 7:03
  • @AmitBera For all user – Parthavi Mar 11 at 8:41
2

You cannot just directly remove this button, but you can remove access to this button

Goto System -> Permissions -> User Roles

Open the role that you want to edit

Under "Additional Cache Management" you will find "Catalog Images Cache" disable it from here

But if you still want to remove this button, you need to override it's phtml file

Add new xml file in Vendor/Module/view/adminhtml/layout/adminhtml_cache_index.xml

code in this file would be:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Backend\Block\Cache\Additional" name="cache.additional" template="Vendor_Module::system/cache/additional.phtml">
                <arguments>
                    <argument name="permissions" xsi:type="object">Magento\Backend\Block\Cache\Permissions</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

And add your phtml file in your module in: Vendor/Module/view/adminhtml/templates/system/cache/additional.phtml use code:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/** @var \Magento\Backend\Block\Cache\Permissions|null $permissions */
$permissions = $block->getData('permissions');
?>
<?php if ($permissions && $permissions->hasAccessToAdditionalActions()): ?>
    <div class="additional-cache-management">
        <?php if ($permissions->hasAccessToFlushCatalogImages()): ?>
            <h2>
                <span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
            </h2>
            <?php /* ?><p>
                <button onclick="setLocation('<?= $block->escapeJs($block->getCleanImagesUrl()); ?>')" type="button">
                    <?= $block->escapeHtml(__('Flush Catalog Images Cache')); ?>
                </button>
                <span><?= $block->escapeHtml(__('Pregenerated product images files')); ?></span>
            </p><?php */ ?>
        <?php endif; ?>
        <?php if ($permissions->hasAccessToFlushJsCss()): ?>
            <p>
                <button onclick="setLocation('<?= $block->escapeJs($block->getCleanMediaUrl()); ?>')" type="button">
                    <?= $block->escapeHtml(__('Flush JavaScript/CSS Cache')); ?>
                </button>
                <span><?= $block->escapeHtml(__('Themes JavaScript and CSS files combined to one file')) ?></span>
            </p>
        <?php endif; ?>
        <?php if (!$block->isInProductionMode() && $permissions->hasAccessToFlushStaticFiles()): ?>
            <p>
                <button onclick="setLocation('<?= $block->escapeJs($block->getCleanStaticFilesUrl()); ?>')" type="button">
                    <?= $block->escapeHtml(__('Flush Static Files Cache')); ?>
                </button>
                <span><?= $block->escapeHtml(__('Preprocessed view files and static files')); ?></span>
            </p>
        <?php endif; ?>
        <?= $block->getChildHtml() ?>
    </div>
<?php endif; ?>
  • I am not able to find "Additional Cache Management" – Parthavi Mar 11 at 6:44
  • System > User Roles > Role Resources – magefms Mar 11 at 6:47
  • Please recheck try search of your browser, screencast.com/t/nQmbQvSXO5S – Shoaib Munir Mar 11 at 6:49
  • Can u give me another solution to disable button – Parthavi Mar 11 at 7:15
  • Sure, let me try – Shoaib Munir Mar 11 at 7:19

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.