Create a function in your ResourceModel
Create a function in your resourceModel like thisapp\code\Module\Namespace\Model\ResourceModel
Inventory.php
<?php
namespace Module\Namespace\Model\ResourceModel;
class Inventory extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
protected function _construct()
{
$this->_init('your table name', 'primary key column name');
}
public function truncateTable()
{
if ($this->getConnection()->getTransactionLevel() > 0) {
$this->getConnection()->delete($this->getMainTable());
} else {
$this->getConnection()->truncateTable($this->getMainTable());
}
return $this;
}
}
and call this function from any file in your custom module. This must delete the table related to the resource.
And call this function from any file in your custom module. This must delete the table related to the resource.