{"id":60441,"date":"2016-09-27T09:33:57","date_gmt":"2016-09-27T09:33:57","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=60441"},"modified":"2022-12-28T12:29:15","modified_gmt":"2022-12-28T12:29:15","slug":"list-taxes-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/","title":{"rendered":"List All Taxes in Magento 2"},"content":{"rendered":"<p>In this dev doc article, we will learn how to list all taxes in Magento 2 platform. Magento manages taxes for catalog, shipping and customers as well.<\/p>\n<p>There have several changes between Magento and Magento 2 in the tax structure. So this article demonstrates how to fetch all taxes in Magento 2.<\/p>\n<blockquote>\n<p style=\"text-align: justify;\">Use below code to retrieve all taxes,<\/p>\n<p style=\"text-align: justify;\">\n<\/blockquote>\n<p><!--more--><\/p>\n<pre class=\"brush:php\">&lt;?php\n \nnamespace Webkul\\Demo\\Model;\n\nuse \\Magento\\Tax\\Model\\Calculation\\Rate;\n \nclass Taxrate extends \\Magento\\Framework\\DataObject \n    implements \\Magento\\Framework\\Option\\ArrayInterface\n{\n    \/**\n     * @var Rate\n     *\/\n    protected $_taxModelConfig;\n     \n    \/**\n     * @param Rate               $taxModelConfig\n     *\/\n    public function __construct(\n        Rate $taxModelConfig\n    ) {\n        $this-&gt;_taxModelConfig = $taxModelConfig;\n    }\n  \n    public function toOptionArray()\n    {\n        $taxRates = $this-&gt;_taxModelConfig-&gt;-&gt;getCollection()-&gt;getData();\n        $taxArray = array();\n        foreach ($taxRates as $tax) {\n            $taxRateId = $tax['tax_calculation_rate_id'];\n            $taxCode = $tax[\"code\"];\n            $taxRate = $tax[\"rate\"];\n            $taxName = $taxCode.'('.$taxRate.'%)';\n            $taxArray[$taxRateId] = $taxName;\n        }\n        return $taxArray;\n    }\n}<\/pre>\n<ul>\n<li><strong>_taxModelConfig:<\/strong> Is an object of &#8220;Magento\\Tax\\Model\\Calculation\\Rate&#8221; class.<\/li>\n<li><strong>$tax[&#8220;code&#8221;] :\u00a0<\/strong>It will give tax code.<\/li>\n<li><strong>$tax[&#8220;rate&#8221;] :\u00a0<\/strong>It will give tax rate.<\/li>\n<li><strong>$tax[&#8220;tax_calculation_rate_id&#8221;] :\u00a0<\/strong>It will give tax id.<\/li>\n<li><strong>toOptionArray() : <\/strong>This method will return a list of taxes with tax rates.<\/li>\n<\/ul>\n<p>Thank you for reading this dev doc on how to list and fetch taxes in Magento 2, we hope you liked it. For more queries, please reach out to our team via a\u00a0<a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\" target=\"_blank\" rel=\"noopener\" data-wpel-link=\"exclude\">support ticket<\/a>.<\/p>\n<p>You may also find a wide range of <a href=\"https:\/\/store.webkul.com\/Magento-2.html\" target=\"_blank\" rel=\"noopener\">Magento 2 extensions<\/a> including <a href=\"https:\/\/store.webkul.com\/magento2-multi-vendor-gst-tax.html\" target=\"_blank\" rel=\"noopener\">Magento 2 GST<\/a> and <a href=\"https:\/\/store.webkul.com\/magento2-multi-vendor-avalara-tax.html\" target=\"_blank\" rel=\"noopener\">Magento 2 Avalara Tax<\/a>, helping you manage and automate complex tax calculations easily.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this dev doc article, we will learn how to list all taxes in Magento 2 platform. Magento manages taxes for catalog, shipping and customers as well. There have several changes between Magento and Magento 2 in the tax structure. So this article demonstrates how to fetch all taxes in Magento 2. Use below code <a href=\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":90,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,3286],"tags":[2070,1041],"class_list":["post-60441","post","type-post","status-publish","format-standard","hentry","category-magento2","category-magento2-1","tag-magento2","tag-tax"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fetch List All Active Taxes in Magento 2<\/title>\n<meta name=\"description\" content=\"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fetch List All Active Taxes in Magento 2\" \/>\n<meta property=\"og:description\" content=\"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-27T09:33:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-28T12:29:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashish Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashish Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\"},\"author\":{\"name\":\"Ashish Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3b92c698256ce0bcb9613acf8bbf5b2d\"},\"headline\":\"List All Taxes in Magento 2\",\"datePublished\":\"2016-09-27T09:33:57+00:00\",\"dateModified\":\"2022-12-28T12:29:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\"},\"wordCount\":168,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Magento2\",\"tax\"],\"articleSection\":[\"Magento2\",\"Magento2.1\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\",\"name\":\"Fetch List All Active Taxes in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2016-09-27T09:33:57+00:00\",\"dateModified\":\"2022-12-28T12:29:15+00:00\",\"description\":\"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"List All Taxes in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/3b92c698256ce0bcb9613acf8bbf5b2d\",\"name\":\"Ashish Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ef2c82640f6054d8a8cfca9e3edd7edaf800ff1873b6d103c7bbf0b47dfefc1e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ef2c82640f6054d8a8cfca9e3edd7edaf800ff1873b6d103c7bbf0b47dfefc1e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ashish Singh\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/ashish067\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fetch List All Active Taxes in Magento 2","description":"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Fetch List All Active Taxes in Magento 2","og_description":"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.","og_url":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-09-27T09:33:57+00:00","article_modified_time":"2022-12-28T12:29:15+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Ashish Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ashish Singh","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/"},"author":{"name":"Ashish Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3b92c698256ce0bcb9613acf8bbf5b2d"},"headline":"List All Taxes in Magento 2","datePublished":"2016-09-27T09:33:57+00:00","dateModified":"2022-12-28T12:29:15+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/"},"wordCount":168,"commentCount":1,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Magento2","tax"],"articleSection":["Magento2","Magento2.1"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/list-taxes-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/","url":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/","name":"Fetch List All Active Taxes in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2016-09-27T09:33:57+00:00","dateModified":"2022-12-28T12:29:15+00:00","description":"How to fetch and list all the taxes in Magento 2, read this dev doc article to find out. Magento and Magento 2 have different tax structures.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/list-taxes-magento2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/list-taxes-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"List All Taxes in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/3b92c698256ce0bcb9613acf8bbf5b2d","name":"Ashish Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ef2c82640f6054d8a8cfca9e3edd7edaf800ff1873b6d103c7bbf0b47dfefc1e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef2c82640f6054d8a8cfca9e3edd7edaf800ff1873b6d103c7bbf0b47dfefc1e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ashish Singh"},"url":"https:\/\/webkul.com\/blog\/author\/ashish067\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/60441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=60441"}],"version-history":[{"count":13,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/60441\/revisions"}],"predecessor-version":[{"id":362219,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/60441\/revisions\/362219"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=60441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=60441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=60441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}