原来某个网店里,就有这个要求。现在要做同样的功能,找了半天,不知从哪里下手,给忘了怎么弄了!
现在记录一下步骤:
1, includes/index_filters/default_filter.php
大概72行的位置,把那段SQL注译了,写:
$listing_sql = "select " . $select_column_list . " p.products_id, p.products_type, p.master_categories_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = 1, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status =1, s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order, p.product_is_call, p.product_is_always_free_shipping, p.products_qty_box_status
from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " .
TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " .
TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p2c.products_id = s.products_id
where p.products_status = 1
and p.products_id = p2c.products_id
and pd.products_id = p2c.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and FIND_IN_SET(p2c.categories_id, F_GET_SUB_CATEGORIES( " . (int)$current_category_id ."))".
$alpha_sort;
2,新建一个存储过程和一个函数到MYSQL里:
--please replace all 'zen' to your database prefix.
DELIMITER //
CREATE PROCEDURE P_GET_SUB_CATEGORIES(IN IN_CATID INT,OUT OUT_IDS VARCHAR(1000))
BEGIN
DECLARE V_STOP BOOLEAN DEFAULT FALSE;
DECLARE V_IDS VARCHAR(1000);
DECLARE V_ID INT;
DECLARE V_SUB_IDS VARCHAR(1000);
DECLARE CUR1 CURSOR FOR SELECT categories_id FROM zen_categories WHERE parent_id = IN_CATID;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET V_STOP = TRUE;
OPEN CUR1;
SET @@max_sp_recursion_depth = 10;
LAB1:WHILE NOT V_STOP DO
FETCH CUR1 INTO V_ID;
IF V_STOP THEN
LEAVE LAB1;
END IF;
CALL P_GET_SUB_CATEGORIES(V_ID,V_SUB_IDS);
SET V_IDS = CONCAT_WS(',',V_IDS,V_ID,V_SUB_IDS);
END WHILE LAB1;
SET OUT_IDS = V_IDS;
END//
CREATE FUNCTION F_GET_SUB_CATEGORIES(IN_CATID INT) RETURNS VARCHAR(3000)
BEGIN
DECLARE V_CATS VARCHAR(1000);
CALL P_GET_SUB_CATEGORIES(IN_CATID,V_CATS);
RETURN CONCAT_WS(',',IN_CATID,V_CATS);
END//
DELIMITER ;
3,includes/modules/pages/index/main_template_vars.php :
大概62行,改成:
if( $category_depth == 'nested______' ){
目的就是不让 $category_depth 不匹配 nested
然后修改:
elseif( $category_depth == 'products' || zen_check_url_get_terms( ) ){
为:
}elseif($category_depth == 'nested' || $category_depth == 'products' || zen_check_url_get_terms( ) ){
OK。
| < Prev | Next > |
|---|



