Many of my friends have installed related product modules, which are difficult to set up.
Release one product. On the product details page, a certain number of similar products are randomly displayed without any settings.
Facilitate search engines to include websites
Benefits for Optimization
This module is taken from LightInTheBox
1. Create a new file with no repeated names. For example, tpl_product_info_similar.php.
Copy the file to the Templates \ template \ Templates \ directory.
Open the file andCodeCopy and save
-
-
Code: select all
-
<Div id = "similar_product">
<H2> related products </H2>
<Ul>
<? PHP $ products_id = (INT) $ _ Get ['products _ id'];
$ Flash_page_id_con = array ();
$ Flash_page_images_con = array ();
$ Flash_page_price_con = array ();
$ Flash_page_name_con = array ();
$ Flash_page_query = "select P. products_id, P. products_image, PD. products_name from ". table_products. "P ,". table_products_description. "PD where p. 'products _ id' = PD. 'products _ id' and PD. 'language _ id' = '". (INT) $ _ session ['AGES _ id']. "'and P. 'Master _ categories_id '= ". zen_get_products_category_id ($ products_id ). "Order by rand () limit 12 ";
$ Flash_page = $ db-> execute ($ flash_page_query );
While (! $ Flash_page-> EOF ){
$ Flash_page_items [] = $ flash_page-> fields;
$ Flash_page_id_con [] = $ flash_page-> fields ['products _ id'];
$ Flash_page_images_src = is_int (strpos ($ flash_page-> fields ['products _ image'], ',')? Substr ($ flash_page-> fields ['products _ image'], 0, strpos ($ flash_page-> fields ['products _ image'], ','): $ flash_page-> fields ['products _ image'];
$ Flash_page_images_con [] = '"'. (zen_not_null ($ flash_page-> fields ['products _ image'])? $ Flash_page_images_src: products_image_no_image ).'"';
$ Flash_page_price_con [] = '"'. $ currencies-> display_price (zen_get_products_base_price ($ flash_page-> fields ['products _ id']), zen_get_tax_rate ($ product_check-> fields ['products _ tax_class_id ']). '"';
$ Flash_page_name_con [] = '"'. zen_output_string (zen_get_products_name ($ flash_page-> fields ['products _ id']). '"';
$ Flash_page-> movenext ();
}
$ Flash_page_id = implode (",", $ flash_page_id_con );
$ Flash_page_images = implode (",", $ flash_page_images_con );
$ Flash_page_price = implode (",", $ flash_page_price_con );
$ Flash_page_name = implode (",", $ flash_page_name_con );
$ Flash_page_display_num = $ flash_page-> recordcount ();
?>
<? PHP for ($ I = 0; $ I <$ flash_page_display_num; $ I ++) {?>
<Li id = "LI <? PHP echo $ I;?> "Style =" display: block; float: Left; padding-left: 10px; width: 22%; ">
<A href = "<? PHP echo zen_href_link (zen_get_info_page ($ flash_page_items [$ I] ['products _ id']), 'products _ id = '. $ flash_page_items [$ I] ['products _ id']);?> "> <? PHP echo zen_image (dir_ws_images. $ flash_page_items [$ I] ['products _ image'], $ flash_page_items [$ I] ['products _ name'], image_featured_products_listing_width, image_featured_products_listing_height);?> </A> <P style = "text-align: center;"> <a href = "<? PHP echo zen_href_link (zen_get_info_page ($ flash_page_items [$ I] ['products _ id']), 'products _ id = '. $ flash_page_items [$ I] ['products _ id']);?> "> <? PHP echo $ flash_page_items [$ I] ['products _ name'];?> </A> <br/> <strong id = "cell_price <? PHP echo $ I?> "> <? PHP echo $ currencies-> display_price (zen_get_products_base_price ($ flash_page_items [$ I] ['products _ id']) = 0? Zen_get_products_sample_price ($ flash_page_items [$ I] ['products _ id']): zen_get_products_base_price ($ flash_page_items [$ I] ['products _ id']), zen_get_tax_rate ($ product_check-> fields ['products _ tax_class_id ']);?> </Strong> </P>
</LI>
<? PHP
// Print_r ($ flash_page_items [$ I]);
}
?>
</Ul>
</Div>
2. Find the Templates \ your template \ Templates \ tpl_product_info_display.php file.
Add the following code to the corresponding location:
<? PHP require ($ template-> get_template_dir ('your created file upload', dir_ws_template, $ current_page_base, 'templates'). '/Your created file tpl_product_info_similar.php');?>
Generally, it can be added to <? PHP require ($ template-> get_template_dir ('tpl _ upload', dir_ws_template, $ current_page_base, 'templates'). '/'. 'TPL _ modules_also_purchased_products.php');?> Above or below