Model/ResourceModel/Catalog.php
public function getProductsCollectionBySku($productsSku, $limit = false)
    {
        $productCollection = [];

        if (! empty($productsSku)) {
            $productCollection = $this->productFactory->create()
                ->getCollection()
                ->addAttributeToSelect(
                    ['product_url', 'name', 'store_id', 'small_image', 'price', 'visibility']
                )->addFieldToFilter('sku', ['in' => $productsSku]);

            if ($limit) {
                $productCollection->getSelect()->limit($limit);
            }
        }

        return $productCollection;
    }
public function getProductsCollectionBySku($productsSku, $limit = false)
    {
        $productCollection = [];

        if (! empty($productsSku)) {
            $productCollection = $this->productFactory->create()
                ->getCollection()
                ->addAttributeToSelect(
                    ['product_url', 'name', 'store_id', 'small_image', 'price', 'visibility']
                )->addFieldToFilter('sku', ['in' => $productsSku]);

            if ($limit) {
                $productCollection->getSelect()->limit($limit);
            }
        }

        return $productCollection;
    }
public function getProductsCollectionBySku ( $ productsSku , $ limit = false ) { $ productCollection = [ ] ; if ( ! empty ( $ productsSku ) ) { $ productCollection = $ this -> productFactory -> create ( ) -> getCollection ( ) -> addAttributeToSelect ( [ 'product_url' , 'name' , 'store_id' , 'small_image' , 'price' , 'visibility' ] ) -> addFieldToFilter ( 'sku' , [ 'in' => $ productsSku ] ) ; if ( $ limit ) { $ productCollection -> getSelect ( ) -> limit ( $ limit ) ; } } return $ productCollection ; }
Get product collection from sku.

@param array $productsSku
@param int|bool $limit

@return array|\Magento\Catalog\Model\ResourceModel\Product\Collection
Get product collection from sku .