1

I have block "product on sale".

<div>
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12">
<div class="row">
<div class="panel-block-row col-md-12">{{block class="MGS\Mpanel\Block\Products\Saleoff" mgs_panel_title="" mgs_panel_note="" limit="40" ratio="4" category_ids="" use_slider="0" loadmore="0" template="products/saleoff.phtml" perrow="4"}}</div>
</div>
</div>
</div>
</div>
</div>

only that it displays all products from the store that are on sale. I would like to limit and display only eg. 100 products on sale.

1 Answer 1

1

Check on that block : MGS\Mpanel\Block\Products\Saleoff

There should be a function which load collection of products so do like as i did change on that collection.

public function getProducts() {
        $collection = $this->_collection
                           ->addMinimalPrice()
                           ->addFinalPrice()
                           ->addTaxPercents()
                           ->addAttributeToSelect('name')
                           ->addAttributeToSelect('image')
                           ->addAttributeToFilter('is_saleable', 1, 'left')
                           ->addAttributeToFilter('featured_product', 1, 'left');
        $collection->getSelect()->limit(100);
        return $collection;
    } 

so add this code like as i did add above.

$collection->getSelect()->limit(100);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.