For Any Website, One crucial necessity is the utilization of Database. Especially for any CMS, it is quite essential to interact with MYSQL with fetching and retrieving of data from the database. Taking about Ecommerce sites Database plays the most important role in managing that store. One of the most used Ecommerce platforms i.e. Magneto 2 is a CMS. In order to store different information like product data, customer data, etc. it utilizes MYSQL.

There are times when a developer wants to perform database operations like storing some data, modifying data or deleting it during coding. But there are certain coding standards in Magento. And according to those standards, a developer has to create a model file in order to perform any SQL query. It is one hectic dilemma in this near-perfect platform for an Ecommerce store.

But what if it was possible to perform those SQL queries without the use of model files. Believe me, it’s possible. And today’s blog is regarding the same. Here I’ll show you how to perform an update query. In the below code update is shown which shows you how to perform an update for any number of times without the use of a modal file. So, let’s start…??

Initially, in order to perform it, you need to create an “Index.php” file inside my extension folder at the path which is defined below.

app\code\Vendor\Extension\Controller\Deletequery\

After creating the folder, you need to apply the below code in order to perform the update operation.

That’s it. With the help of this code, you can execute multiple SQL update operations without creating a model file. Without creating a standard Magento 2 Model file can be very helpful in your development phase.

lastly,?If This blog was helpful, then don’t forget to share it with your Magneto friends. Along with that if you are facing any difficulty or error during the implementation of this code, just let us know.

Happy Coding! ?‍??‍?

[Total: 8   Average: 4/5]