Display Promotion & Random Products in Magento

1,983 人次阅读
没有评论

共计 1774 个字符,预计需要花费 5 分钟才能阅读完成。

There are two unused product list blocks in Magento which can be very useful if you push a few buttons, edit few layouts ..

 

1. Promotion
Block located in app\code\core\Mage\Catalog\Block\Product\List\Promotion.php

This is basically built in featured product functionality. It reacts to “promotion” attribute which needs to be created, so let’s click
Catalog->Attributes->Manage Attributes->Create New Attribute

Attribute Code: promotion
Scope: Global
Catalog Input Type for Store Owner: Yes/No

Display Promotion & Random Products in Magento

Label: Promotion (second tab)

Other params can be left alone, but it’s up to you of course. I also labeled it Promotion just for this article.

Now we need to add created attribute to attribute set, so navigate to
Catalog->Attributes->Manage Attribute Sets
select attribute set you’re using and drag promotion to General group for example.

Display Promotion & Random Products in Magento

Now when you’re editing your products, there is new “Promotion” option under General tab.

Display Promotion & Random Products in Magento

Products on which you select Yes will be shown on promotion block which can be displayed through layouts with

<block type=”catalog/product_list_promotion” name=”product_promotion” template=”catalog/product/list.phtml”/>

or as cms content with

{{block type=’catalog/product_list_promotion’ template=’catalog/product/list.phtml’}}

This attribute should really be included in default attribute set or in Magento sample data.

2. Random
Block located in app\code\core\Mage\Catalog\Block\Product\List\Random.php

This block loads random product collection from current store.

The fastest way to display it would also be something like

<block type=”catalog/product_list_random” name=”product_random” template=”catalog/product/list.phtml”/>

since it also extends product_list block, however, since it is random product listing, that toolbar has no purpose here, so create phtml that will suit your shop needs, based on catalog/product/list.phtml. For example, i’m using similar Random block to display random products in sidebar.

So long, take care, i’m off …

From:http://inchoo.net/ecommerce/magento/promotion-and-random/

正文完
 0