private function getSortedProducts()
    {
        $products   = [];
        $productIds = $this->getSortedProductIds();

        if ($productIds && count($productIds)) {
            $productCollection = $this->getProductCollection()->setPageSize(count($productIds));

            $idFilterParams = ['values' => $productIds, 'field' => 'entity_id'];
            $idFilter       = $this->queryFactory->create(QueryInterface::TYPE_TERMS, $idFilterParams);
            $productCollection->addQueryFilter($idFilter);

            $products = $productCollection->getItems();
        }

        $sortedProducts = [];

        foreach ($this->getSortedProductIds() as $productId) {
            if (isset($products[$productId])) {
                $sortedProducts[$productId] = $products[$productId];
            }
        }

        return $sortedProducts;
    }
private function getSortedProducts()
    {
        $products   = [];
        $productIds = $this->getSortedProductIds();

        if ($productIds && count($productIds)) {
            $productCollection = $this->getProductCollection()->setPageSize(count($productIds));

            $idFilterParams = ['values' => $productIds, 'field' => 'entity_id'];
            $idFilter       = $this->queryFactory->create(QueryInterface::TYPE_TERMS, $idFilterParams);
            $productCollection->addQueryFilter($idFilter);

            $products = $productCollection->getItems();
        }

        $sortedProducts = [];

        foreach ($this->getSortedProductIds() as $productId) {
            if (isset($products[$productId])) {
                $sortedProducts[$productId] = $products[$productId];
            }
        }

        return $sortedProducts;
    }
private function getSortedProducts ( ) { $ products = [ ] ; $ productIds = $ this -> getSortedProductIds ( ) ; if ( $ productIds && count ( $ productIds ) ) { $ productCollection = $ this -> getProductCollection ( ) -> setPageSize ( count ( $ productIds ) ) ; $ idFilterParams = [ 'values' => $ productIds , 'field' => 'entity_id' ] ; $ idFilter = $ this -> queryFactory -> create ( QueryInterface :: TYPE_TERMS , $ idFilterParams ) ; $ productCollection -> addQueryFilter ( $ idFilter ) ; $ products = $ productCollection -> getItems ( ) ; } $ sortedProducts = [ ] ; foreach ( $ this -> getSortedProductIds ( ) as $ productId ) { if ( isset ( $ products [ $ productId ] ) ) { $ sortedProducts [ $ productId ] = $ products [ $ productId ] ; } } return $ sortedProducts ; }
Return a collection with all products manually sorted loaded.

@return \Magento\Catalog\Api\Data\ProductInterface[]
Return a collection with all products manually sorted loaded .