For some reasons Magento doesn’t have generic functionality to list best selling products, all products with discounted prices (specials), all products in the inventory in general or products with specific attributes (like all products of a specific manufacturer). All those listings share almost the same functionality so I decided to combine them into one Magento extension which I named Custom_Listings.
The extension uses a practice of injecting a listing into a CMS page, the practice Magento already utilizes for displaying new products or custom category listings. The listing can be inserted by either using the `{{block}}` shortcode or widget. For bestsellers, specials and all products the shortcodes are pretty much the same:
{{block type="custom_listing/bestsellers" name="my_bestsellers" template="catalog/product/list.phtml"}} {{block type="custom_listing/specials" name="my_specials" template="catalog/product/list.phtml"}} {{block type="custom_listing/all" name="my-all-products" template="catalog/product/list.phtml"}}
The block name just has to be something unique. The default Magento product listing template is used, but you can easily replace it with your own.
With a listing based on an attribute value the shortcode is a bit different:
{{block type="custom_listing/attribute" name="my_manufacturer" template="catalog/product/list.phtml" attribute="ATTRIBUTE_CODE" value="ATTRIBUTE_VALUE"}}
So you need to know the attribute code (e.g. manufacturer, color, weight) and the attribute value for text field, text area, data or price type attributes. For dropdowns and multiple selects you need the attribute value’s option ID.
Getting this ID may be a bit tricky. You either have to get it directly from the database or look at the HTML markup of the Edit Product Attribute screen and retrieve the ID from the «name» attribute of the corresponding <input> tag. In the following example it would be the ID 28:
<input name="option[value][28][0]" value="Acer" class="input-text required-option" type="text" kl_vkbd_parsed="true">
I’m really sorry for the lack of usability, an attribute selector is in the planning and will be available for the corresponding widget.
Yeah, each block has a widget in case you don’t want to mess up with `{{block}}` shortcodes. Never heard about Magento admin widgets? Here is a good article.
The extension can be installed from either MagentoConnect or GitHub. Pull requests and functionality improvement suggestions are welcome, as always.
Special thanks to Vinai Kopp for his help with widgets support and the toolbar handler.
Schreibe einen Kommentar