getObjectManager();
$appState = $objectManager->get(\Magento\Framework\App\State::class);
try {
$appState->setAreaCode('frontend');
} catch (\Exception $e) {}
$storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
$storeManager->setCurrentStore(1);
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\CollectionFactory $factory */
$factory = $objectManager->get(\Magento\CatalogSearch\Model\ResourceModel\Fulltext\CollectionFactory::class);
$collection = $factory->create();
$collection->setStoreId(1);
$collection->addAttributeToSelect(['name', 'sku']);
$collection->addSearchFilter('TNWX-0668N');
$collection->setPageSize(10);
echo "Store ID: " . $storeManager->getStore()->getId() . PHP_EOL;
echo "Size: " . $collection->getSize() . PHP_EOL;
foreach ($collection as $item) {
echo $item->getSku() . " | " . $item->getName() . PHP_EOL;
}