1

I need to show MSRP price in a custom module template, but I cant get it.

I have Magento\Catalog\Model\Product model and $product->getMsrp() or $product->getData('msrp') does not return value (NULL).

The product exists and other basic data (like id, name etc) too.

Where might be a problem?

1

Use below code for msrp display.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
       $product = $objectManager->get('Magento\Catalog\Model\Product')->load(14);
       echo "<pre>"; print_r($product->getData());
       echo "Msrp :".$product->getMsrp());

enter image description here

enter image description here

0

Found solution, in block file:

public function __construct(
    ...
    Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    ...
) {
    ...

    $this->productRepository = $productRepository;
}


public function getMsrpPrice($id)
{
    $product = $this->productRepository->getById($id);
    return $product->getMsrp();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.