1

Is there a way to remove the delete button from the manage products backend? I understand that this would make it impossible to remove products. Preferably, it would not require a change to the core.

8
  • Hei MagentoNoob, Welcome to Magento Stackeexchange. if you dont want to delete a product, then ignore that button. Why would you bother to delete it ? Could you please explain the reason by editing your question ? Commented Jan 27, 2015 at 1:56
  • @programmer_rkt - Ever worked with a team of 'content editors' who seem to not have that ability, to ignore delete buttons.
    – ProxiBlue
    Commented Jan 27, 2015 at 4:48
  • @ProxiBlue : I am sorry. I didn't get your point actually !!!! Commented Jan 27, 2015 at 5:05
  • 1
    @programmer_rkt : Staff manages your products, and product content. Periodically products seem to disappear. Your developer finds that the products were deleted. You tell the staff to ignore the delete button (as suggested) A week later you find that products have again been deleted (accidents happen)
    – ProxiBlue
    Commented Jan 27, 2015 at 5:30
  • 1
    @programmer_rkt - I agree - consider the fact that you can also delete via mass-action from the grid, making hiding a button pointless as well. MagentoNoob - understanding your requirements/why would help. I also don't understand why people are voting for this to be closed. There is a clear question being asked. We may not agree with what is being asked, but that for me does not justify closing the question.
    – ProxiBlue
    Commented Jan 27, 2015 at 5:42

3 Answers 3

5

If you are worried of people accidentally clicking the delete button you can take the simple approach @Prashanta suggested. Hiding it via css. It should work.
If you want to completely remove the delete button and the delete action you need to rewrite the product edit block and the product admin controller. You also need to remove the mass action delete from the grid.
For this you will need a custom extension. Let's call it StackExchange_Catalog.
You will need the following files.

app/etc/modules/StackExchange_Catalog.xml - the declaration file

<?xml version="1.0"?>
<config>
    <modules>
        <StackExchange_Catalog>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Catalog />
                <Mage_Adminhtml />
            </depends>
        </StackExchange_Catalog>
    </modules>
</config>

app/code/local/StackExchange/Catalog/etc/config.xml - the configuration file

<?xml version="1.0"?>
<config>
    <modules>
        <StackExchange_Catalog>
            <version>1.0.0</version>
        </StackExchange_Catalog>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <catalog_product_edit>StackExchange_Catalog_Block_Adminhtml_Product_Edit</catalog_product_edit><!-- remove the delete button -->
                    <catalog_product_grid>StackExchange_Catalog_Block_Adminhtml_Product_Grid</catalog_product_grid><!-- remove the mass action delete -->
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules><!-- disallow delete actions -->
                        <StackExchange_Catalog before="Mage_Adminhtml">StackExchange_Catalog_Adminhtml</StackExchange_Catalog>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

app/code/local/StackExchange/Catalog/Block/Adminhtml/Product/Edit.php - your version of the product edit block

<?php
class StackExchange_Catalog_Block_Adminhtml_Product_Edit extends Mage_Adminhtml_Block_Catalog_Product_Edit
{
    /**
     * no delete button for you
     * @return string
     */
    public function getDeleteButtonHtml()
    {
        return '';
    }
}

/app/code/local/StackExchange/Catalog/Block/Adminhtml/Product/Grid.php - your grid version that removes the mass action delete.

<?php
class StackExchange_Catalog_Block_Adminhtml_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
{
    protected function _prepareMassaction()
    {
        parent::_prepareMassaction();
        $this->getMassactionBlock()->removeItem('delete');
        return $this;
    }
}

app/code/local/StackExchange/Catalog/controllers/Adminhtml/Catalog/ProductController.php - your new product controller that disables the delete action just in case someone guesses the delete URL. This should never happen but let's be paranoid.

<?php
require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
class StackExchange_Catalog_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
{
    /**
     * just redirect to index on the delete action
     */
    public function deleteAction()
    {
        $this->_getSession()->addWarning($this->__('Product deletion is prohibited'));
        $this->_redirect('*/*/index');
    }

    /**
     * don't allow mass delete either
     */
    public function massDeleteAction()
    {
        $this->_getSession()->addWarning($this->__('Product deletion is prohibited'));
        $this->_redirect('*/*/index');
    }
}
1
  • Oh, thank you so much! The only full and complete answer on this entire "internet" thing.
    – Roy Toledo
    Commented Mar 29, 2019 at 2:56
1

Just use plain and simple css. Add this code to your css file.

.adminhtml-catalog-product-edit button.delete { display: none; }
1
  • It is not a Magento way. You may say this as a tiny hack. Marius answer is perfect.
    – Adnan
    Commented Nov 15, 2016 at 12:20
0

Here below simple way to remove delete button from admin panel.For that override Mage_Catalog_Model_Product in your extension as below

<global>
    <models>
      <catalog>
        <rewrite>
          <product>MY_PACKAGE_Model_Product</product>
        </rewrite>
      </catalog>
    </models>
  </global>

Now create new Product.php file in Model with below code.

class MY_PACKAGE_Model_Product extends Mage_Catalog_Model_Product
{
    protected $_isDuplicable = false; // Remove Duplicate Button
    protected $_isDeleteable = false; // Remove Delete Button
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.