I quite often get asked how to achieve this easily by friends and colleagues and in there defence it's not 'clearly' documented. So I thought i'd knock something up really quickly to show you how it can be done.
In this example I create a category called 'Featured' and I importantly set the 'API code' for this category to 'featured'. This is found at the very bottom of the category creation / edit page.
I want to pull in some featured products into my homepage so I dive into the CMS and pull up the homepage.
You'll want to enter the below snippet into the template.
$category = Shop_Category::create()->find_by_code('featured'); $this->render_partial('shop:product_list', array( 'products'=>$category->list_products()->find_all() )) ?>
This snippet first fetches the correct category object and then renders a partial called shop:product_list (or shop;product_list.htm if you use template based files) with all of the products under this category.
Now you just need to make your partial and add some basic code to it.
I'm not going to dive into the full extent of what you can now do with the below code but just get you on your way.
In your shop:product_list partial add the following code:
= h($product->short_description) ?>
And that's all there is to it. You'll now be getting a list of all the products in this category on your homepage. Of course it is also worth noting you could use this same partial in many places across your site. It's use will probably largely depend on how heavily uniform or customised the section on your site is.
Hope this is of some use.