zoukankan      html  css  js  c++  java
  • zencart通过产品id 批量添加推荐产品

    1.修改 admin/featured.php

    查找 pre_add_confirmation

    将 pre_add_confirmation 与  break; 之间的代码,用下面的代码替换即可

    <?php
     
     case 'pre_add_confirmation':
          // check for blank or existing featured
    
            $pre_add_products_id=$_POST['pre_add_products_id'];
            $pre_add_products_id2=explode(',',$pre_add_products_id);
            foreach($pre_add_products_id2 as $key=>$val) {
                $sql = "select products_id from " . TABLE_PRODUCTS . " where products_id='" . (int)$val . "'";
                $check_featured = $db->Execute($sql);
                if ($check_featured->RecordCount() == 1) {
                    $sql = "select products_id from " . TABLE_FEATURED . " where products_id='" . (int)$val . "'";
                    $check_featured = $db->Execute($sql);
                    if ($check_featured->RecordCount() < 1) {
                        // add empty featured
                        $featured_date_available = ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start']));
                        $expires_date = ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']));
                        $products_id = zen_db_prepare_input($val);
                        $db->Execute("insert into " . TABLE_FEATURED . " (products_id, featured_date_added, expires_date, status, featured_date_available)
                            values ('" . (int)$products_id . "', now(), '" . zen_db_input($expires_date) . "', '1', '" . zen_db_input($featured_date_available) . "')");
                    }
                }     
            }
            break;
    ?>


    2.adminincludesfunctionsgeneral.php

    查找 函数 zen_set_field_length

    在这个函数下面 增加以下函数即可

      function zen_set_field_length_1000($max=50, $override=false) {
        $field_length= 1000;
        switch (true) {
          case (($override == false and $field_length > $max)):
            $length= 'size = "' . ($max+1) . '" maxlength= "' . $field_length . '"';
            break;
          default:
            $length= 'size = "' . ($field_length+1) . '" maxlength = "' . $field_length . '"';
            break;
        }
        return $length;
      }


    3. 做完上面2步后 就可以 通过后台 Catalog --> Featured Products --> 点击右边的 Product ID to be Manually Added as a Featured按钮
    然后在文本框中输入产品的id, 产品id之间用英文逗号隔开,列如 21,55,23,89

    转载请注明出处!小鱼阁工作室 -专注zencart建站,织梦企业建站,ecshop商城,二次开发,产品采集,模板修改!技术QQ 631992791
  • 相关阅读:
    pair和map
    lower_bound( )和upper_bound( )
    P1886 滑动窗口 /【模板】单调队列
    数的度(数位dp)
    最小生成树
    刷题-力扣-1052. 爱生气的书店老板
    刷题-力扣-766. 托普利茨矩阵
    刷题-力扣-28. 实现 strStr()
    刷题-力扣-697. 数组的度
    刷题-力扣-1004. 最大连续1的个数 III
  • 原文地址:https://www.cnblogs.com/afish/p/3924590.html
Copyright © 2011-2022 走看看