Magento 2 : How to get the best seller product collection?Add Category filter in best seller product...

Why do neural networks need so many training examples to perform?

How much time does it take for a broken magnet to recover its poles?

Which aircraft had such a luxurious-looking navigator's station?

Finding an integral using a table?

Why is my solution for the partial pressures of two different gases incorrect?

Where is this triangular-shaped space station from?

4 Spheres all touching each other??

How to approximate rolls for potions of healing using only d6's?

What's the rationale behind the objections to these measures against human trafficking?

Connecting top and bottom of adjacent circles

Meaning of すきっとした

How do we edit a novel that's written by several people?

Proof by Induction - New to proofs

What's a good word to describe a public place that looks like it wouldn't be rough?

Meth dealer reference in Family Guy

Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?

Why is commutativity optional in multiplication for rings?

Do authors have to be politically correct in article-writing?

Is Draco canonically good-looking?

Predict mars robot position

What is the meaning of "pick up" in this sentence?

What is the wife of a henpecked husband called?

raspberry pi change directory (cd) command not working with USB drive

Finding the number of integers that are a square and a cube at the same time



Magento 2 : How to get the best seller product collection?


Add Category filter in best seller product CollectionGet product collection filter by from and to date in magento2.Magento 2 get out of stock products in collectionMagento2: How to update the product price programaticallyMagento 2 : get best seller product on daily basisget Product not work - Magento 2Get product collection by store ID on Magento 2.2Get Product id in magento2Magento2 REST API get all customers detailsget invoice item using order_item_id in magento 2













3















I'm trying to get Best Seller Product collection using below code, but it will not display any data



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productCollection = $objectManager->create('MagentoSalesModelResourceModelReportBestsellersCollectionFactory');
$collection = $productCollection->create()->setModel('MagentoCatalogModelProduct')->setPeriod('yearly');


How to get Best Seller Product collection ?










share|improve this question

























  • it might not working because you have set "yearly" instead of "year", please check my ans for more information.

    – Aasim Goriya
    Feb 13 at 9:51
















3















I'm trying to get Best Seller Product collection using below code, but it will not display any data



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productCollection = $objectManager->create('MagentoSalesModelResourceModelReportBestsellersCollectionFactory');
$collection = $productCollection->create()->setModel('MagentoCatalogModelProduct')->setPeriod('yearly');


How to get Best Seller Product collection ?










share|improve this question

























  • it might not working because you have set "yearly" instead of "year", please check my ans for more information.

    – Aasim Goriya
    Feb 13 at 9:51














3












3








3








I'm trying to get Best Seller Product collection using below code, but it will not display any data



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productCollection = $objectManager->create('MagentoSalesModelResourceModelReportBestsellersCollectionFactory');
$collection = $productCollection->create()->setModel('MagentoCatalogModelProduct')->setPeriod('yearly');


How to get Best Seller Product collection ?










share|improve this question
















I'm trying to get Best Seller Product collection using below code, but it will not display any data



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productCollection = $objectManager->create('MagentoSalesModelResourceModelReportBestsellersCollectionFactory');
$collection = $productCollection->create()->setModel('MagentoCatalogModelProduct')->setPeriod('yearly');


How to get Best Seller Product collection ?







magento2 magento2.3 php-7 magento2.3.0 best-seller






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 14 mins ago









Aasim Goriya

3,8791938




3,8791938










asked Feb 13 at 9:47









Mayur JotaniyaMayur Jotaniya

9410




9410













  • it might not working because you have set "yearly" instead of "year", please check my ans for more information.

    – Aasim Goriya
    Feb 13 at 9:51



















  • it might not working because you have set "yearly" instead of "year", please check my ans for more information.

    – Aasim Goriya
    Feb 13 at 9:51

















it might not working because you have set "yearly" instead of "year", please check my ans for more information.

– Aasim Goriya
Feb 13 at 9:51





it might not working because you have set "yearly" instead of "year", please check my ans for more information.

– Aasim Goriya
Feb 13 at 9:51










1 Answer
1






active

oldest

votes


















4














Please try this code to get best seller product collections using objectManager.



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$productCollection = $objectManager->create('MagentoReportsModelResourceModelReportCollectionFactory');
$collection = $productCollection->create('MagentoSalesModelResourceModelReportBestsellersCollection');

$collection->setPeriod('year');
//$collection->setPeriod('month');
//$collection->setPeriod('day');

foreach ($collection as $item) {
print_r($item->getData());
}





share|improve this answer

























    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%2f261560%2fmagento-2-how-to-get-the-best-seller-product-collection%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









    4














    Please try this code to get best seller product collections using objectManager.



    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $productCollection = $objectManager->create('MagentoReportsModelResourceModelReportCollectionFactory');
    $collection = $productCollection->create('MagentoSalesModelResourceModelReportBestsellersCollection');

    $collection->setPeriod('year');
    //$collection->setPeriod('month');
    //$collection->setPeriod('day');

    foreach ($collection as $item) {
    print_r($item->getData());
    }





    share|improve this answer






























      4














      Please try this code to get best seller product collections using objectManager.



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $productCollection = $objectManager->create('MagentoReportsModelResourceModelReportCollectionFactory');
      $collection = $productCollection->create('MagentoSalesModelResourceModelReportBestsellersCollection');

      $collection->setPeriod('year');
      //$collection->setPeriod('month');
      //$collection->setPeriod('day');

      foreach ($collection as $item) {
      print_r($item->getData());
      }





      share|improve this answer




























        4












        4








        4







        Please try this code to get best seller product collections using objectManager.



        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $productCollection = $objectManager->create('MagentoReportsModelResourceModelReportCollectionFactory');
        $collection = $productCollection->create('MagentoSalesModelResourceModelReportBestsellersCollection');

        $collection->setPeriod('year');
        //$collection->setPeriod('month');
        //$collection->setPeriod('day');

        foreach ($collection as $item) {
        print_r($item->getData());
        }





        share|improve this answer















        Please try this code to get best seller product collections using objectManager.



        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $productCollection = $objectManager->create('MagentoReportsModelResourceModelReportCollectionFactory');
        $collection = $productCollection->create('MagentoSalesModelResourceModelReportBestsellersCollection');

        $collection->setPeriod('year');
        //$collection->setPeriod('month');
        //$collection->setPeriod('day');

        foreach ($collection as $item) {
        print_r($item->getData());
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 19 at 4:32

























        answered Feb 13 at 9:49









        Aasim GoriyaAasim Goriya

        3,8791938




        3,8791938






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f261560%2fmagento-2-how-to-get-the-best-seller-product-collection%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

            “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

            How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

            變成蝙蝠會怎樣? 參考資料 外部連結 导航菜单Thomas Nagel, "What is it like to be a...