I have only one product in the catalog with sku "prodotto". The product is in the default category, it is also visible on frontend (I can see it and browse to it on frontend), it is in stock, it has positive quantity. It is set to be visible and set to display in Catalog, Search, and it is enabled. I can see it in the table catalog_product_entity. However, when I try to check for this product by its sku ("prodotto"), I am getting the message:
Product with Sku: prodotto not found in the catalog.
This is my code:
$connection = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER) -> getObjectManager() -> get("\Magento\Framework\App\ResourceConnection") -> getConnection();
$sql = "SELECT COUNT(*) AS count_no FROM " . _getTableName('catalog_product_entity') . " WHERE sku = ?";
try {
$count = $connection -> fetchAll($sql, array('prodotto'));
} catch (PDOException $pdoe) {
echo $pdoe;
} catch (Exception $e) {
echo $e;
}
Why is this hapenning?