I'm using magento 2, I created some tables that I fill with entries then I want to delete all those entries at once. I want the solution to use Magento repository abd without using a foreach. Something like deleteAll for example.
Thanks alot.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI'm using magento 2, I created some tables that I fill with entries then I want to delete all those entries at once. I want the solution to use Magento repository abd without using a foreach. Something like deleteAll for example.
Thanks alot.
If you need to delete all the data row from the database table then you can be used the below code to truncate the table using the model.
$connection = $model->getCollection()->getConnection();
$tableName = $model->getCollection()->getMainTable();
$connection->truncateTable($tableName);
I hope this is helpful to you!!