Magento 2 Best Seller Collection Limit












1














Magento 2 Best Seller Collection:



<?php

namespace MPSAllproductBlockIndex;


class Index extends MagentoFrameworkViewElementTemplate {


protected $_coreRegistry = null;
protected $_collectionFactory;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoSalesModelResourceModelReportBestsellersCollectionFactory $collectionFactory,
array $data =
) {
$this->_collectionFactory = $collectionFactory;
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}



public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getBestSellerData()
{
$collection = $this->_collectionFactory->create()->setModel(
'MagentoCatalogModelProduct'
);

return $collection;
}

}


I used above collection but it always show 5 products only but I don't know how it will work.



How to reset count. In My Collection is correct?










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1














    Magento 2 Best Seller Collection:



    <?php

    namespace MPSAllproductBlockIndex;


    class Index extends MagentoFrameworkViewElementTemplate {


    protected $_coreRegistry = null;
    protected $_collectionFactory;

    public function __construct(
    MagentoBackendBlockTemplateContext $context,
    MagentoFrameworkRegistry $registry,
    MagentoSalesModelResourceModelReportBestsellersCollectionFactory $collectionFactory,
    array $data =
    ) {
    $this->_collectionFactory = $collectionFactory;
    $this->_coreRegistry = $registry;
    parent::__construct($context, $data);
    }



    public function _prepareLayout()
    {
    return parent::_prepareLayout();
    }
    public function getBestSellerData()
    {
    $collection = $this->_collectionFactory->create()->setModel(
    'MagentoCatalogModelProduct'
    );

    return $collection;
    }

    }


    I used above collection but it always show 5 products only but I don't know how it will work.



    How to reset count. In My Collection is correct?










    share|improve this question
















    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1







      Magento 2 Best Seller Collection:



      <?php

      namespace MPSAllproductBlockIndex;


      class Index extends MagentoFrameworkViewElementTemplate {


      protected $_coreRegistry = null;
      protected $_collectionFactory;

      public function __construct(
      MagentoBackendBlockTemplateContext $context,
      MagentoFrameworkRegistry $registry,
      MagentoSalesModelResourceModelReportBestsellersCollectionFactory $collectionFactory,
      array $data =
      ) {
      $this->_collectionFactory = $collectionFactory;
      $this->_coreRegistry = $registry;
      parent::__construct($context, $data);
      }



      public function _prepareLayout()
      {
      return parent::_prepareLayout();
      }
      public function getBestSellerData()
      {
      $collection = $this->_collectionFactory->create()->setModel(
      'MagentoCatalogModelProduct'
      );

      return $collection;
      }

      }


      I used above collection but it always show 5 products only but I don't know how it will work.



      How to reset count. In My Collection is correct?










      share|improve this question















      Magento 2 Best Seller Collection:



      <?php

      namespace MPSAllproductBlockIndex;


      class Index extends MagentoFrameworkViewElementTemplate {


      protected $_coreRegistry = null;
      protected $_collectionFactory;

      public function __construct(
      MagentoBackendBlockTemplateContext $context,
      MagentoFrameworkRegistry $registry,
      MagentoSalesModelResourceModelReportBestsellersCollectionFactory $collectionFactory,
      array $data =
      ) {
      $this->_collectionFactory = $collectionFactory;
      $this->_coreRegistry = $registry;
      parent::__construct($context, $data);
      }



      public function _prepareLayout()
      {
      return parent::_prepareLayout();
      }
      public function getBestSellerData()
      {
      $collection = $this->_collectionFactory->create()->setModel(
      'MagentoCatalogModelProduct'
      );

      return $collection;
      }

      }


      I used above collection but it always show 5 products only but I don't know how it will work.



      How to reset count. In My Collection is correct?







      magento2 product-collection best-seller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 14 '18 at 5:52









      Teja Bhagavan Kollepara

      2,93841847




      2,93841847










      asked May 3 '17 at 15:11









      my Testmy Test

      2510




      2510





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit:



          /**
          * Rating limit
          *
          * @var int
          */
          protected $_ratingLimit = 5;


          We can try to reset the default limit, and then set the new one:



          $dataCollection = $collection->getSelect();
          $dataCollection->reset(MagentoFrameworkDBSelect::LIMIT_COUNT);
          $dataCollection->limit(20); // Set custom limit





          share|improve this answer























          • Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
            – my Test
            May 3 '17 at 15:28










          • Seem that you're calling count() method some wherelse?
            – Khoa TruongDinh
            May 3 '17 at 15:33












          • i removed count still 5 record only
            – my Test
            May 3 '17 at 15:35










          • We should return $dataCollection.
            – Khoa TruongDinh
            May 3 '17 at 15:37












          • Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
            – my Test
            May 3 '17 at 15:38











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f172862%2fmagento-2-best-seller-collection-limit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit:



          /**
          * Rating limit
          *
          * @var int
          */
          protected $_ratingLimit = 5;


          We can try to reset the default limit, and then set the new one:



          $dataCollection = $collection->getSelect();
          $dataCollection->reset(MagentoFrameworkDBSelect::LIMIT_COUNT);
          $dataCollection->limit(20); // Set custom limit





          share|improve this answer























          • Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
            – my Test
            May 3 '17 at 15:28










          • Seem that you're calling count() method some wherelse?
            – Khoa TruongDinh
            May 3 '17 at 15:33












          • i removed count still 5 record only
            – my Test
            May 3 '17 at 15:35










          • We should return $dataCollection.
            – Khoa TruongDinh
            May 3 '17 at 15:37












          • Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
            – my Test
            May 3 '17 at 15:38
















          0














          Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit:



          /**
          * Rating limit
          *
          * @var int
          */
          protected $_ratingLimit = 5;


          We can try to reset the default limit, and then set the new one:



          $dataCollection = $collection->getSelect();
          $dataCollection->reset(MagentoFrameworkDBSelect::LIMIT_COUNT);
          $dataCollection->limit(20); // Set custom limit





          share|improve this answer























          • Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
            – my Test
            May 3 '17 at 15:28










          • Seem that you're calling count() method some wherelse?
            – Khoa TruongDinh
            May 3 '17 at 15:33












          • i removed count still 5 record only
            – my Test
            May 3 '17 at 15:35










          • We should return $dataCollection.
            – Khoa TruongDinh
            May 3 '17 at 15:37












          • Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
            – my Test
            May 3 '17 at 15:38














          0












          0








          0






          Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit:



          /**
          * Rating limit
          *
          * @var int
          */
          protected $_ratingLimit = 5;


          We can try to reset the default limit, and then set the new one:



          $dataCollection = $collection->getSelect();
          $dataCollection->reset(MagentoFrameworkDBSelect::LIMIT_COUNT);
          $dataCollection->limit(20); // Set custom limit





          share|improve this answer














          Take a look: vendor/magento/module-sales/Model/ResourceModel/Report/Bestsellers/Collection.php. We can see the limit:



          /**
          * Rating limit
          *
          * @var int
          */
          protected $_ratingLimit = 5;


          We can try to reset the default limit, and then set the new one:



          $dataCollection = $collection->getSelect();
          $dataCollection->reset(MagentoFrameworkDBSelect::LIMIT_COUNT);
          $dataCollection->limit(20); // Set custom limit






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 3 '17 at 15:28

























          answered May 3 '17 at 15:20









          Khoa TruongDinhKhoa TruongDinh

          21k63984




          21k63984












          • Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
            – my Test
            May 3 '17 at 15:28










          • Seem that you're calling count() method some wherelse?
            – Khoa TruongDinh
            May 3 '17 at 15:33












          • i removed count still 5 record only
            – my Test
            May 3 '17 at 15:35










          • We should return $dataCollection.
            – Khoa TruongDinh
            May 3 '17 at 15:37












          • Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
            – my Test
            May 3 '17 at 15:38


















          • Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
            – my Test
            May 3 '17 at 15:28










          • Seem that you're calling count() method some wherelse?
            – Khoa TruongDinh
            May 3 '17 at 15:33












          • i removed count still 5 record only
            – my Test
            May 3 '17 at 15:35










          • We should return $dataCollection.
            – Khoa TruongDinh
            May 3 '17 at 15:37












          • Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
            – my Test
            May 3 '17 at 15:38
















          Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
          – my Test
          May 3 '17 at 15:28




          Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'count()'
          – my Test
          May 3 '17 at 15:28












          Seem that you're calling count() method some wherelse?
          – Khoa TruongDinh
          May 3 '17 at 15:33






          Seem that you're calling count() method some wherelse?
          – Khoa TruongDinh
          May 3 '17 at 15:33














          i removed count still 5 record only
          – my Test
          May 3 '17 at 15:35




          i removed count still 5 record only
          – my Test
          May 3 '17 at 15:35












          We should return $dataCollection.
          – Khoa TruongDinh
          May 3 '17 at 15:37






          We should return $dataCollection.
          – Khoa TruongDinh
          May 3 '17 at 15:37














          Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
          – my Test
          May 3 '17 at 15:38




          Still same Exception #0 (Zend_Db_Select_Exception): Unrecognized method 'getSize()'
          – my Test
          May 3 '17 at 15:38


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f172862%2fmagento-2-best-seller-collection-limit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          An IMO inspired problem

          Management

          Has there ever been an instance of an active nuclear power plant within or near a war zone?