Creating a Best-Sellers Category with Magento

Magento allows you to organize products in categories, and a single product can be a member of quite a few separate categories. As a result, you can create a category that is specifically for your top selling products. You could manually keep track of which products sell the best, either by number of sales completed, or by the actual quantity of each product that were sold. If you want to spend all your time managing this category, then this is the way to go. However, there is a much easier way to manage the products in the category.

Automatically Add Products to a Category

Adding the top-selling products to your Popular Products category is something that takes a bit of thought and planning before implementing it due to some of the restrictions that Magento places on developers working with products and categories. The flow for doing this would be to first get the list of all products that are currently in the Popular Products. Once we have the list of products currently in the Popular Products category, we can remove all of these products from the category, ensuring we do remove products from the category that are no longer popular. Once the category is emptied, we would need to get the list of product ids for the popular products. Once we have this new list of products, we can add them all to the Popular Products category, set the position of the products in the category, and then view the category page that shows our most popular products.

Unfortunately, there is no direct way to set the position of a product in a category by using either the Product or Category collections. However, you can utilize the Category API, which is used for the web services API, and utilize it to add the product to the category and order it properly. While this works, it is not the most elegant solution.

Tags:
comments powered by Disqus

Related Posts

Magento Cache with Cache Disabled

One of the things that I find quite annoying with a web platform is when you configure it to do one thing, and it does something different. Magento is an eCommerce software platform that many of the leading eCommerce websites use for their web stores. Magento Magento comes in two different flavors, a paid enterprise edition as well as a open-source community edition. The enterprise edition allows you to utilize the built-in full-page caching mechanism, while the community edition does not include a full-page caching solution.

Read More

Magento FrontName Naming and SSL/HTTPS

One of the things that has always been an issue for sites that are based on Magento is that they are slow. Well, to be fair, sites using Magento Enterprise Edition that take advantage of the built-in full-page caching functionality seem to have decent page load times. One way to take care of this slow load time issue is to utilize a third-party full-page caching solution such as what Varnish provides.

Read More

Launching a Redesign of a Website

Over the last few months, I have been working on a major redesign of an existing Magento website. One of the major goals of the redesign was to take a legacy desktop-only website and upgrade it to take full advantage of Responsive Web Design so that customers could equally utilize mobile and desktop devices to browse and purchase products. For a site that had seen only minor updates over the last 5 years, this redesign represented a major change visually and navigationally from the previous site.

Read More