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);
$terms = ['Poussette', 'Lettres', 'Table', 'TNWX-0668N'];
foreach ($terms as $term) {
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\SearchCollection $collection */
$collection = $objectManager->create(\Magento\CatalogSearch\Model\ResourceModel\Fulltext\SearchCollection::class);
$collection->setStoreId(1);
$collection->addAttributeToSelect(['name', 'sku']);
$collection->addSearchFilter($term);
$collection->setPageSize(10);
echo "==== TERM: {$term} ====\n";
echo "SIZE: " . $collection->getSize() . "\n";
foreach ($collection as $item) {
echo $item->getSku() . " | " . $item->getName() . "\n";
}
echo "\n";
}