I have started to learnam learning magento and I have some doubts about how it works, could someone help me with it or can suggest some tutorial from where I can learn more about magento. In
/app/design/frontend/../../template/catalog/product/widget/new/content/new_grid.phtml
file there is a piece of code
$this->getProductCollection()
I know this function can be found in
/app/code/core/Mage/Catalog/Block/Product/Widget/New.php
But there is no such function, I also looked in the parent class and there also I could not find this function.
I found another function in
/app/code/core/Mage/Catalog/Block/Product/Widget/New.php
Below is the function
protected function _getProductCollection()
{
switch ($this->getDisplayType()) {
case self::DISPLAY_TYPE_NEW_PRODUCTS:
$collection = parent::_getProductCollection();
break;
default:
$collection = $this->_getRecentlyAddedProductsCollection();
break;
}
return $collection;
}
and I know this function is called but my question is why and how? These two have different names then how they can be same. Do it means that "_" is only used if a function is protected and it does not have to do anything with the function name.
And also when I echoed
$this->getDisplayType()
then I got 'new_products' but if you see in this function then magento is using self::DISPLAY_TYPE_NEW_PRODUCTS in case then how these two cases or strings are similar.
Also please explain this line
parent::_getProductCollection()
do it means call _getProductCollection() from parent class and if yes then where this is specified in magento.