> Zencart中文手册 > zencart系统如何推荐商品

zencart系统如何推荐商品 

 
1:zencart系统推荐商品

后台->商品管理->推荐商品,在列表中选择商品,选择推荐的时间段,提交.

2:zencart系统推荐商品的实现原理

1:tpl_box_default_left.PHP中,$box_id是循环整个产品推荐模块的一个根本,而column_left.php又 是循环选择模块标题和模块内容的一个模板.于是通过require(DIR_WS_MODULES . ’sideboxes/’ . $column_left_display->fields['layout_box_name']);来实现对tpl_default.php的 包含.tpl_default.php中的 $ranDOM_featured_product = $db->ExecuteRandomMulti($random_featured_products_query, MAX_RANDOM_SELECT_FEATURED_PRODUCTS);
数组,把要包含的推荐产品条数记录下来。传递给tpl_default.php.

tpl_default.php是产品推荐的模块.下面的代码是对推荐产品的处理.

$content = “”;
$featured_box_counter = 0;
while (!$random_featured_product->EOF) {
$featured_box_counter++;
$featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
$content .= ‘<div>’;
$content .= ‘<a href=”‘ . zen_href_link(zen_get_info_page($random_featured_product->fields["products_id"]), ‘cPath=’ . zen_get_generated_category_path_rev($random_featured_product->fields["master_categories_id"]) . ‘&products_id=’ . $random_featured_product->fields["products_id"]) . ‘”>’ . zen_image(DIR_WS_IMAGES . $random_featured_product->fields['products_image'], $random_featured_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
$content .= ‘<br />’ . $random_featured_product->fields['products_name'] . ‘</a>’;
$content .= ‘<div>’ . $featured_box_price . ‘</div>’;
$content .= ‘</div>’;
$random_featured_product->MoveNextRandom();
}