Select Popular Products

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
NewUser
Posts: 8
Joined: 22 Mar 2017, 05:01

Select Popular Products

Post by NewUser » 27 Mar 2017, 05:10

I need to select the popular products from a list of products. mshop_product is the database table name for the list of products. But here, there is no field marked as popular product or something like that. Is there a way to fetch the popular products from the database table? If so, which is that table and the corresponding table name?

gilbertsoft
Posts: 28
Joined: 18 Nov 2016, 10:35

Re: Select Popular Products

Post by gilbertsoft » 27 Mar 2017, 14:31

Are you talking about Promotions? If yes, have a look at typo3conf/ext/aimeos/Resources/private/Extensions/ai-client-html/client/html/src/Client/Html/Catalog/Lists/Promo/Standard.php. There you find the filter params in the function setViewParams on the bottom of the code.

The related tables are mshop_catalog, mshop_catalog_list, mshop_catalog_list_type and mshop_product.

NewUser
Posts: 8
Joined: 22 Mar 2017, 05:01

Re: Select Popular Products

Post by NewUser » 27 Mar 2017, 14:45

I am not talking about promotions. I need to display the popular products. It can be on the basis of the number of buyers. If one particular product is bought by many customers, it is said to be as a popular product. Like that, whether there is any way to fetch such informations??
Currently what I did was, I created another category named popular products and dropped the products into that category. Is that a way for making popular products view in the frontend?

gilbertsoft
Posts: 28
Joined: 18 Nov 2016, 10:35

Re: Select Popular Products

Post by gilbertsoft » 27 Mar 2017, 17:31

Yes, but depends on your requirements or how and where you want to show the products.

An other solution can be creating a new list type (like the promotions) in mshop_catalog_list_type and show the assigned products in top of the product list like promotions are done or like you need it. Have a look at the files mentioned in the last post and the corresponding templates in typo3conf/ext/aimeos/Resources/Private/Extensions/ai-client-html/client/html/templates/catalog/lists/. So you are able to assign the products to every category you want to and not only showing them in one category.

To get the whole thing automated on sells you have to adapt the fetching of the products in the function setViewParams. Of course then you don't anymore need the new list type to filter the products.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Select Popular Products

Post by aimeos » 27 Mar 2017, 21:25

You can do the following:
- Sorting by relevance is just sorting by positions within a category, so you can change the product positions in the categories (manually or automatically)
- Create a new category including all products with positions according the number of sold products (manually or automatically)

To do this automatically, you should create a new job controller that sets the positions accordingly:
https://aimeos.org/docs/Developers/Cont ... controller

Retrieving the ordered products and their count is rather easy:

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' );
$search = $manager->createSearch( true );
$map = $manager->aggregateItems( $search, 'order.base.product.productid' );
To get all products in bunches, please read this article: https://aimeos.org/docs/Developers/Fetc ... in_bunches
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply