I have a category "pre-order". How can I have the products from this category shows at the end of product search results page?

i found this plug-in to have the out of stock display in the ned, how to i have the product in category id:123 to show up at the end?

 * @author Rakesh Jesadiya
 * @package Rbj_OutOfStock

namespace Rbj\OutOfStock\Plugin\Product\ProductList;

class Toolbar
     * @param \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $subject
     * @param bool $printQuery
     * @param bool $logQuery
     * @return array
    public function beforeLoad(\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $subject, $printQuery = false, $logQuery = false)
        $orderBy = $subject->getSelect()->getPart(\Zend_Db_Select::ORDER);

        $outOfStockOrderBy = array('is_salable DESC');

        /* how to i get the array of products from category 123"? */

        /* reset default product collection filter */

        return [$printQuery, $logQuery];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.