Skip to content
A Craft CMS 3 plugin to get best selling products.
PHP
Branch: master
Clone or download
Latest commit 58d8643 Dec 28, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Initial Commit Dec 28, 2018
.craftplugin Initial Commit Dec 28, 2018
.gitignore Initial Commit Dec 28, 2018
CHANGELOG.md
LICENSE Initial commit Dec 28, 2018
LICENSE.md Initial Commit Dec 28, 2018
README.md Updated Readme Dec 28, 2018
composer.json Initial Commit Dec 28, 2018

README.md

Best Seller Products plugin for Craft CMS 3.x

Best Seller Product is a Craft CMS plugin that helps you to get best selling products in your Commerce Store.

Requirements

  • Craft CMS 3.x
  • Craft Commerce 2.x

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require by/best-seller-products
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Best Seller Products.

Using Best Seller Products

To simply get a list of best selling product IDs, use :

{% set bestSellerProductIds = craft.bestSellerProducts.getBSPIds(limit) %}
{% set bestsellers = craft.products.id(bestSellerProductIds).all() %}

To get the Number of Times a product has been bought, use:

{% for bsp in craft.bestSellerProducts.getBSP(limit) %}
    {{ bsp.purchasableId }} -- {{ bsp.times_bought }}
{% endfor %}

craft.bestSellerProducts.getBSP(limit) will return an array cointaing purchasableId and times_bought

limit is the no. of products you would like to get. Default is 10


Brought to you by Bhashkar Yadav

You can’t perform that action at this time.