Skip to content

how to get custom product attribute value in model file in magento2

I have created a custom product attribute using data patch in my custom module and it is visible in product configuration in admin, also when I save value in it, it get save to catalog_product_entity_int table, now I want to get its value in custom model but its not accessible. I tried like:

$product->getEnableSubscription() //enable_subscription is attribute name
$product->getData(‘enable_subscription’)

I added attribute in product backend only and want to fetch its value saved from admin panel.