I have a question about a specific product collection on a cms page
I have an amount X of products which have an attribute A which is set to true.
Now I want to have a cms page with some content and then have a number of X products on that page where the attribute is true.
I thought of creating a block and then in that block load the collection and then go through that collection until a certain number is reached
$collection->addFieldToFilter(array(
array('attribute'=>'is_set','eq'=='true'),
));
Then integrate that block in the cms page
{{block type="custom/list" name="custom_list" template="custom/list.phtml}}
But I want to show X number of products and in 6 columns and wonder how I would achieve this in that way?
Thanks
Best Answer
This can be done with a widget. You can set the widget in the admin panel on a CMS block or a CMS page.
Creating a Widget in Magento
We will need the following files:
Define Our Module
Create a Config File:
Create a Widget Config
Create a Helper
(For translation)
Create a Widget Block Class
Create Template File
Using The Widget
Now, you can go to your admin panel and set the widget directly:
You can also set the widget directly with this:
Summary
This is a basic example. You can go crazy with widgets. You can even define the attribute to filter with!
I hope this helps. Good luck with your widget making!