---
title: "How to get a Special Price of the Product in Magento 2"
url: "https://magecomp.com/blog/get-special-price-product-magento-2/"
date: "2019-05-24T16:54:52+00:00"
modified: "2025-02-21T11:14:33+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 333
reading_time: "2 min read"
summary: "Magento 2 is one of featured pack CMS that comes with tons of preloaded configurations that makes it a perfect fit for any business. Even if you are setting up price for the product you can set 3 d..."
description: "Magento 2 is one of featured pack CMS that comes with tons of preloaded configurations that makes it&hellip;"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to add Multi-select Filter in Backend Admin Grid of Magento 2?"
    url: "https://magecomp.com/blog/add-multi-select-filter-backend-admin-grid-magento-2/"
  - title: "Magento 2: How to Assign Products to Category Programmatically using Root File"
    url: "https://magecomp.com/blog/magento-2-assign-products-to-category-programmatically-using-root-file/"
  - title: "How to Programmatically Export CSV File Category Name with Parent Category Name using Root Script in Magento 2?"
    url: "https://magecomp.com/blog/programmatically-export-csv-file-category-name-with-parent-category-name-using-root-script-magento-2/"
---

# How to get a Special Price of the Product in Magento 2

_Published: May 24, 2019_  
_Author: Dhiren Vasoya_  

![How to get special price of the product in Magento 2](https://magecomp.com/blog/wp-content/uploads/2019/05/How-to-get-special-price-of-the-product-in-Magento-2-1024x332.webp)

Magento 2 is one of featured pack CMS that comes with tons of preloaded configurations that makes it a perfect fit for any business. Even if you are setting up price for the product you can set 3 different kinds of prices including Group price, Special price & Tier price depending on your business needs. Several times it happens when the store owner is offering some of the store products at a discounted price for the specific period of time. During that specified time period, the special price appears instead of the regular price in the Magento 2 front, followed by a notation that shows the regular price.

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-3.webp)](https://magecomp.com/services/hyva-theme-development/)
Several times, it happens that while developing any payment related extension or functionality, the developer first needs to check that the product contains any special price or offered at a normal price before performing any pricing related operations. Because if any product contains a special price, then the base product price for the calculations will be special pricing, not the regular price. So, we are again back with a small piece of code that will help you to get the special price of the product in Magento 2.
Simply place below code anywhere in your extension or development to check that product contains special price or not.

```
Use below code to check if product have special price or not
$specialprice = $_product->getSpecialPrice();
$specialfromdate = $_product->getSpecialFromDate();
$specialtodate = $_product->getSpecialToDate();
$today = time();

   if ((is_null($specialfromdate) &&is_null($specialtodate)) || ($today >=
    strtotime($specialfromdate) &&is_null($specialtodate)) || ($today <=
    strtotime($specialtodate) &&is_null($specialfromdate)) || ($today >=
    strtotime($specialfromdate) && $today <= strtotime($specialtodate))) {
    $specialPriceExist = true;
   }else{
     $specialPriceExist = false;
   }
```

[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-1.webp)](https://magecomp.com/services/magento-upgrade-services/)

then you can check like below in your code.

```
$specialPriceExist ? $specialPriceExist : $_product->getCustomUnitAmount()*$_product->getPricePerCustomUnit()
```

That’s it! If you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends.

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2023/10/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)
And, Let us know if you are facing an issue while implementing this code.
Happy Coding!


---

_View the original post at: [https://magecomp.com/blog/get-special-price-product-magento-2/](https://magecomp.com/blog/get-special-price-product-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-04 01:17:19 UTC_  
