Home > Net >  How to get special price magento 2
How to get special price magento 2

Time:11-28

How can i add the special_price on magento.catalog_product_entity_decimal using joins.

attribute_id 77 = price and i need also special price attribute_id 78

enter image description here

CodePudding user response:

You can use Subquery to get the result Here is the SQL Query you can use to get the data -

SELECT catprod.entity_id,catprod.value,catprod.value_id,catprod.store_id,catprod.attribute_id,(SELECT value FROM catalog_product_entity_decimal WHERE attribute_id=78 AND entity_id=catprod.entity_id) AS special_price FROM catalog_product_entity_decimal AS catprod WHERE attribute_id = 77;

See Result Image

The Above link show to data of price and special price in a row of products , those which are not having special price will be NULL.

CodePudding user response:

use Magento/Catalog/Model/ProductFactory to load product, and get price information from the model

$specialPrice = $this->productFactory()->create()->load($id)->getPriceInfo()->getPrice('special_price');

  • Related