{"id":1635,"date":"2021-03-11T04:06:10","date_gmt":"2021-03-11T04:06:10","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/get-product-status-in-magento-2\/"},"modified":"2025-07-17T09:39:08","modified_gmt":"2025-07-17T04:09:08","slug":"get-product-status-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-product-status-in-magento-2\/","title":{"rendered":"How to Get Product Status in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2\u00a0storefront displays products that are enabled from the backend to the store visitors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apart from whether to display the product to visitors or not, there are other tasks where you need product status.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before doing any product-related task, we have to check whether the product is enabled or not in the frontend. To do so, we need to&nbsp;get product status in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, while sending data to a third-party API, it requires sending only enabled products\u2019 data and exclude the disabled products.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, while generating different types of reports in the Magento 2 store, one may only want to get the data of the enabled products. To implement such a solution, one may need to get product status in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The product status is the current status of a particular product.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 product status has two different states:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enabled:&nbsp;<\/strong>The product is visible or enabled in the frontend.<\/li>\n\n\n\n<li><strong>Disabled:&nbsp;<\/strong>The product is not visible or disabled in the frontend.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In order to get product status programmatically in Magento 2, use the below method:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Get Product Status in Magento 2<\/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=\"\">&lt;?php\n\nuse Magento\\Catalog\\Model\\Product;\n\nprotected $product;\n\npublic function __construct(Product $product)\n{\n    $this->product = $product;\n}\n\npublic function getIsProductEnable($productId)\n{\n    $product = $this->product->load($productId);\n    return $product->getStatus();\n    \/\/ 2 means Disabled , 1 means Enabled\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the product is enabled, it returns 1 and if the product is disabled, it returns 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to 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>Magento 2\u00a0storefront displays products that are enabled from the backend to the store visitors. Apart from whether to display the product to visitors or not,&#8230;<\/p>\n","protected":false},"author":13,"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-1635","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1635","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1635"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1635\/revisions"}],"predecessor-version":[{"id":18180,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1635\/revisions\/18180"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}