cancel
Showing results for 
Search instead for 
Did you mean: 

Where to find the renderLayout Controller

Where to find the renderLayout Controller

I am new to the Block /  Layout concept, but trying hard to get an understanding of it.

I have a customer home.phtml, where I have this line : 

$categoryId = $this->getData('category_id');
 
This fetches me a category ID.
I need to find where is this category_id is getting set.
 
The Block for this phtml is List.php, and there when I try to do Mage::log($this->getData()), I get following object : 

(
[type] => catalog/product_list
[column_count] => 4
[category_id] => 67
[product_count] => 12
[attribute_filter] => price_sync::eq::0,price_sync::null::true
[template] => catalog/product/home.phtml
[block_params] => Array
(
[type] => catalog/product_list
[column_count] => 4
[category_id] => 67
[product_count] => 12
[attribute_filter] => price_sync::eq::0,price_sync::null::true
[template] => catalog/product/home.phtml
)

[module_name] => Dbaux_CPAsSubProduct_Catalog
)

So, what I am trying to find is where is this value getting set. Please let me know if I can do anything.

4 REPLIES 4

Re: Where to find the renderLayout Controller

@torrtugaco0bda 

As shared code I can see you are calling blocks for products on home page.

It's catalog product list block, you can find app/code/core/Mage/Catalog/Block/Product/List.php. In this file, you can see many methods: getLoadedProductCollection(), _getProductCollection(),setCategoryId(), getCategoryId(), etc. For example: when you set category_id = 2 => getCategoryId() will get your category id = 2. In your template, it will calls a function $this->getLoadedProductCollection() .

Manish Mittal
https://www.manishmittal.com/

Re: Where to find the renderLayout Controller

In the List.php, For 
_getProductCollection() method, the category Id value is already set, I have shared a piece of code where the $this object already has the value. 
And I am trying to understand how its loaded in the $this object.

if
($this->getCategoryId()) {
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
if ($category->getId()) {
$origCategory = $layer->getCurrentCategory();

Edit : Infact inside 
_beforeToHtml() method only $this is having the category Id values.
$layer->setCurrentCategory($category);
$this->addModelTags($category);
}
}

Re: Where to find the renderLayout Controller

@torrtugaco0bda 

 

Here $this is block class you can find out this class using 

echo get_class($this);

You can check this class where you can find defined render layout for this. 

Manish Mittal
https://www.manishmittal.com/

Re: Where to find the renderLayout Controller

I get my custom 

CompanyName_CPAsSubProduct_Catalog_Block_Product_List as the class name over here.

Which when called
_getProductCollection calls parent::_getProductCollection
But in the custom class there is no place where I am setting the categoryId.

Is it possible that the $this variable is getting value from some other class?