Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6594947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:52:35+00:00 2026-05-25T17:52:35+00:00

I have been working on a custom module for Magento (ver. 1.8.0.0) that shows

  • 0

I have been working on a custom module for Magento (ver. 1.8.0.0) that shows a list of related products of a certain product.

In order to achieve this I have created my own module by overwriting the Mage_Catalog_Block_Product_List class.

Basically here’s how it works:

From a controller I catch the products entity_id and I store the product in the registry so I can use it inside my custom written Block which is called list.php

Here is the method that fills the product collection:

protected function _getProductCollection()
{
    if (is_null($this->_productCollection)) {
        $prod = Mage::registry('chosenproduct');
        $this->_productCollection = $prod->getRelatedProductCollection()
            ->addAttributeToSelect('required_options')
            ->addAttributeToFilter(array(array('attribute'=>'accessory_manufacturer','neq'=>false)))
            ->addAttributeToSort('position', 'asc')
            ->addStoreFilter()
            ->setPageSize(30)
            ->setCurPage(1);
        ;

        $this->_addProductAttributesAndPrices($this->_productCollection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_productCollection);
        $this->setProductCollection($this->_productCollection);
    }

    return $this->_productCollection;
}

I also added the following in the layout .xml of my custom module to make sure the layered navigation shows:

<reference name="left">
        <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
    </reference>

The layered navigation shows, but it seems that it is taking all products as collection instead of the custom collection that is used in the method I added above.

I also know that I can get the catalog/layer using this $layer = Mage::getSingleton('catalog/layer');

The layer class also has a method called prepareProductCollection and setCollection but for some reason I can’t get it to work.

Any help on this?

Basically I want to have the layered navigation for the products that are in the custom collection.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:52:36+00:00Added an answer on May 25, 2026 at 5:52 pm

    I just managed to achieve what I wanted. I have overwritten both the Mage_Catalog_Model_Layer class and the Mage_Catalog_Model_Category

    Both now have a new variable called $_customCollection: protected $_customProductCollection;

    I have overwritten the getProductCollection() in both classes and I added this in the beginning of the method:

    if(isset($this->_customProductCollection)){
            return $this->_customProductCollection;
        }
    

    I have also a method that allows me to set this “customProductCollection” inside both these classes. Once It’s set, the rest of the data of the layered navigation/category is based on this collection.

    😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom module using Magento's EAV structure and have been
I've been working on a custom module that has a backend for admin. Until
I am new to Spring Security. I have been working on creating a custom
I have been using hook_alter to modify forms in a custom PHP module. I
I have been trying to get a custom inventory script working in unrealscript. I
So I have been working with Wordpress 3.x and trying to build a custom
I have been working on a project that takes a MySQL dump and restores
Greetings, I have been working on a custom namespace in appcelerator but have run
I have been working on a JSON parser for a little while https://github.com/nathanday/ndjson that
I have been working on a custom CMS and I would like to work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.