{"id":922,"date":"2020-03-31T13:03:44","date_gmt":"2020-03-31T13:03:44","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/03\/31\/insert-record-in-database-in-magento\/"},"modified":"2025-05-22T14:38:50","modified_gmt":"2025-05-22T09:08:50","slug":"insert-record-in-database-in-magento","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/insert-record-in-database-in-magento\/","title":{"rendered":"Learn the One Simple Method To Insert Record In Database In Magento"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The popularity of Magento lies in its ability for customization and flexibility to fulfil the business requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One such example below is the code to&nbsp;<em><strong>insert record in database in Magento<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It allows inserting a record in the table in Magento 1. For example, you created a table named \u201cTest\u201d. Now you want to insert record in that already created table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Insert data in the table in Magento, easily, using the below solution:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to insert record in database in Magento:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$model = Mage::getModel('modulename\/modelname');\n$model->setData($yourData);\n$model->save();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Please share the solution with Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The popularity of Magento lies in its ability for customization and flexibility to fulfil the business requirements. One such example below is the code to&nbsp;insert&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-922","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=922"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/922\/revisions"}],"predecessor-version":[{"id":14998,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/922\/revisions\/14998"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}