I have created an extension that creates product attribute "Is Old" after installing extension. Attribute is in drop down form with Yes and No.
Attribute value is saving in "catalog_product_entity_int" table.
The main purpose of creating this attribute is that admin can decide if current product is old or not.
Now I want to fetch all those product's entity id that is set to "YES" in "Is Old" drop down value and by specific SKU.
I have fetched product's entity id by SKU but now I want to fetch entity id by sku and is_old value "Yes" as well.
Here is my code to fetch product entity id by SKU only.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$select = "Select * FROM catalog_product_entity WHERE sku='123'";
$rowArray = $connection->fetchRow($select);
$enitity_id = $rowArray['entity_id'];