I need to get the special price of a product by product Id or Sku. Let's say I have an existing product with Id '21' and Sku 'test-21'.
This information is provided in my custom block class, how can I get the special price of this product in mentioned custom class?
Best Answer
use
Magento/Catalog/Model/ProductFactory
to load product, and get price information from the modelCode is like:
some reference about how to get product model in your custom module
use object manager: http://alanstorm.com/magento_2_object_manager_instance_objects/
use dependency injection: http://www.coolryan.com/magento/2016/01/27/dependency-injection-in-magento-2/
Normally dependency injection is recommended.