I am working in Magento 2. I need to get getTireprice
,getSpecialprice
and getfinalprice
?
Anyone please provide same code for this.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI am working in Magento 2. I need to get getTireprice
,getSpecialprice
and getfinalprice
?
Anyone please provide same code for this.
Step 1: Create a customtest.php and copy the below code and paste in the customtest.php and run it.
Step 2: customtest.php
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
//product Information
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product')->load(1);
echo "Product Name ==".$product->getName()."<br>";
echo "product price ===".$product->getPrice()."<br>";
echo "product final price ===".$product->getFinalPrice()."<br>";//
echo "product special price ===".$product->getSpecialPrice()."<br>";
getAnyGroupData($product); //custom function
function getAnyGroupData($product)
{
$tierPrice=$product->getTierPrices();
if(count($tierPrice) > 0)
{
foreach ($tierPrice as $price)
{
echo "Tier Price Value ==".$price->getValue()."<br>";
}
}
}
?>
screenshots: