I want to sort my product custom price instead of Magento default price. By default product price is '0'.

I overwrite /vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php.

I set my custom product price in public function setCollection($collection){ ... }.

I do not set a custom price for product collection. When I print product collection after set price. It always displays '0'.

Here is my code,

public function setCollection($collection)
    $this->_collection = $collection;

    // we need to set pagination only if passed value integer and more that 0
    $limit = (int) $this->getLimit();
    if ($limit) {
    foreach ($this->_collection as $key => $value) {
        $price = 20;
    if ($this->getCurrentOrder()) {
        $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());

    return $this;

How to set custom price in product collection($this->_collection)?

And how to sort product by custom price?

  • I also got the same issue. did you find any solution for this? – Shailesh Katarmal Oct 10 '19 at 23:44

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.