If you are importing via Mage_ImportExport
there is also an option "DELETE". If you apply this on the same import file, all SKUs contained in this file will be deleted.
In code this is ->setBehavior(Mage_ImportExport_Model_Import::BEHAVIOR_DELETE);
You still can truncate the specific product tables via SQL - but of course you have to resolve all the dependencies and also truncate those tables.
Or: Create a "clean" database dump before importing and apply this dump before each test.
Hope you know the how to work with observer in magento.
you have to create observer for that for this and dynamically add tab in your admin product view.
so first thing I will give explain in detail first you have to create your custom module for that
you have to create a two observer
Observer code which you have to write in config.xml file
-----
<adminhtml>
<events>
<core_block_abstract_prepare_layout_after>
<observers>
<namespace_productupload_injectTabs>
<type>singleton</type>
<class>productupload/observer_product</class>
<method>injectTabs</method>
</namespace_productupload_injectTabs>
</observers>
</core_block_abstract_prepare_layout_after>
</events>
</adminhtml>
-----
1) core_block_abstract_prepare_layout_after
when this event will call this method setTab() called. which I have mention below.
public function setTab(Varien_Event_Observer $observer)
{
$block = $observer->getEvent()->getBlock();
if (Mage::getStoreConfig('productupload/general/enabled',Mage::app()->getStore()) && $block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
if ($this->_getRequest()->getActionName() == 'edit' || $this->_getRequest()->getParam('type')) {
$block->addTab('custom-product-tab-01', array(
'label' => 'Upload Product Files',
'content' => $block->getLayout()->createBlock('adminhtml/template', 'custom-tab-content', array('template' => 'productupload/content.phtml'))->toHtml()
));
}
}
}
you have to create the phtml file. it will call each time when you open your product open as edit or new mode.
app\design\adminhtml\default\default\template\productupload\content.phtml
2) catalog_product_save_after
in this observer you have to write the code when you save your product. because Magento will not provide the file attribute. so we have to create the save logic via code.
Best Answer
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 fileapp/code/local/StackExchange/Catalog/etc/config.xml
- the configuration fileapp/code/local/StackExchange/Catalog/Block/Adminhtml/Product/Edit.php
- your version of the product edit block/app/code/local/StackExchange/Catalog/Block/Adminhtml/Product/Grid.php
- your grid version that removes the mass action delete.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.