Just a discerning one currently though that competence be useful in some situations. You might find yourself wanting to arrangement products from a difficulty in some form of navigation. You might also wish to arrangement an charge in that menu object too.
Here’s one approach to do it:
function getCatProds($catid) {
$category = new Mage_Catalog_Model_Category();
$category-load($catid); // this is your special offers difficulty id!
$collection = $category-getProductCollection();
foreach($collection as $product) {
$id[] = $product-getId();
}
$html = "ul";
foreach($id as $id){
$product = Mage::getModel('catalog/product')-load($id); /* Load Products by ID*/
$name = trim($prod_model-getName());
$link = "/".Mage::getModel('catalog/product_url')-getUrlPath($prod_model);
$attribute = trim($prod_model-getAttributeText('colour')); // get charge text
$html .= "lia href="".$link."" title="".$attribute." ".$name.""".$attribute." ".$name."/a/li";
}
$html .= "/ul";
echo $html;
}As we can see we have combined a duty that we can call when we wish to relate out a new menu. If we demeanour closely we can see this will move behind a product name, authorized url and a charge colour.
All we need to do to move this behind is govern a duty with a difficulty ID we wish to arrangement a products from.
?php getCatProds(12); ?
This will emanate a new menu nicely. If we were a garments store and wanted to move behind a opposite phony t-shirts for example, we would call a t-shirts difficulty and arrangement a products along with their tradition attribute.
Which will give us a result:
ul lia href="/t-shirt-1.html" title="Blue T-Shirt"Red T-Shirt/a/li lia href="/t-shirt-2.html" title="Red T-Shirt"Blue T-Shirt/a/li /ul
It is good seo use to have this arrange of thing on your website as it does widespread a product links easily from your high-ranking pages – such as your homepage.
