Get product_Id using following query,
public function getProductsIdBySku($skus)
{
$select = $this->getReadConnection()
->select()
->from($this->getTable('catalog/product'), array('entity_id'))
->where('sku IN (?)', (array) $skus);
return $this->getReadConnection()->fetchCol($select);
}
use \Magento\Catalog\Model\ResourceModel\Product\Collection;
I'm trying to do that in magento2...
$collection = $this->_productCollection->getCollection()->addFieldToSelect('*');
$collection->getSelect()
->reset(\Magento\Framework\DB\Select::COLUMNS)
->columns('entity_id');
->where('sku = ?', (array) $skus);
return $collection;
Its not working for me....If any mistakes in my query ..
Thanks.