I have an online e-commerce project which focuses on selling paintings from different artists. These products have been assigned to sub-categories of the artists name.

Category structure:

Root Category

If I were to build a plugin where the client is able to limit the products shown per the artist's name, e.g only show 2 paintings of artist_1 on the 1st products page, only show 1 painting of artist_32, only show 4 paintings of artist_13 etc etc.(no limit to the rest of the pages) Which way would I have to go to be able to accomplish this particular function? I know that you can manually do this by manually entering the position of each product within a category.

Here is a mockup of how the plugin might look like: Product Arranger Screenshot

1 Answer 1


This is a too too broad question. Effectively you are asking for an extension which are going to use custom tables. So take this answer as a generalized answer.

As I said before, you need to create a new table that will use to store artist_reference, category_reference, filter_type, size_limit. You need to then use this table in both admin and frontend. Let me call this table as artist_category_reference.

> SELECT * FROM `artist_category_reference` LIMIT 1;
|  id  |  artist_reference  |  category_reference  |  filter_type  |  size_limit  |
|  1   |       3            |          5           |    created    |      4       |

artist_reference   : id of artist. Other than category if you have a table to refer for an artist, then you can use this for referring to that entity. Otherwise, you can store category_id here. In that case  3 column is not required.
category_reference : category id correspond to artist
filter_type        : use to store ASC or  DESC and filter type.
size_limit         : what should be the page size of artist category

You can now observe to an event controller_action_layout_generate_blocks_after and set new page size limit to the category toolbar block. For this, your observer somewhat look like this.

class Namespace_Module_Model_Observer

    public function setPageSizeForCategory(Varien_Event_Observer $observer)
        $currentCategory = Mage::registry('current_category');

        //check whether current page is a category page
        if ($currentCategory instanceof Mage_Catalog_Model_Category) {

            //eventhough this is a collection, this collection should hold
            //only one artist reference item. ie in your table, for a particular
            //category reference, there should be only one entry.
            $ArtistReference = Mage::getModel('namespace_module/reference')
                ->addFieldToFilter('category_reference', $currentCategory->getId())

            //set page size
            foreach ($ArtistReference as $artist) {
                if (isset($artist->getId())) {
                    //check whether toolbar block exist or not
                    $toolbar =  $observer->getLayout()->getBlock('product_list_toolbar');
                    if ($toolbar) {
                        //sets page size to corresponding mode
                        $listMode = $toolbar->getCurrentMode();
                        $toolbar = $toolbar->addPagerLimit($listMode , $artist->getSizeLimit());

        return $this;

This is just a blueprint of how your observer should look like. Here what I have done is, if the page that is requested is a category page and is an artist category, then grab the size_limit from artist_category_reference table and then set the toolbar page size to that value.

So this is just a blue print, in the similar way you should apply your custom filter too. I hope this will give you a general idea.

Not the answer you're looking for? Browse other questions tagged or ask your own question.