And also explain following function:
Mage::getModel('catalog/product');
load();
$category = Mage::getModel('catalog/category');
$category->load($categoryid);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('*');
The Mage
is a super-class used to obtain access to the main methods/processes used in Magento.
Mage::getModel('catalog/product');
returns new (empty) instance of the Mage_Catalog_Model_Product
class.
load()
- the regular method of AbstractModel
in Magento which loads corresponding model's data from the database.
$category = Mage::getModel('catalog/category');
- get new category model and store it in the $category
variable. Later you can add a data to it and save it using save()
.
$category->load($categoryid);
- loads from the databse specific category in case when the $category
is instance of AbstractModel
.
$collection = $category->getProductCollection();
- returns the collection of a products for this category. Each of them is instance of Mage_Catalog_Model_Product
.
$collection->addAttributeToSelect('*');
- select all of the available attributes during future load process. In case when the collection was already loaded will give no effect.