zencart批量插入TEXT文本属性attributes

有时候上传的产品与多级分类比较多,在后台添加文本属性如Name,Number等需要顾客自定义的内容就比较费神了。现在只需将以下代码保存为insert_attributes.php,变量$options_id_array,$current_category_id修改为实际的值,上传到网站根目录运行即可一步到位。

<?php
//header("content-Type: text/html; charset=utf-8"); 
@set_time_limit(1800);
@ini_set('memory_limit','100M');
require('includes/application_top.php');
$options_id_array = array(2,3); //文本属性对应的ID数组
$current_category_id = 99; //要批量设置文本属性的产品分类ID

$categories_products_list = zen_get_categories_products_list($current_category_id);
$plist_array = array();
foreach($categories_products_list as $key => $value){
    $plist_array[] = $key;
}
//print_r($plist_array);

foreach($plist_array as $pid){    
    foreach($options_id_array as $optid){
        $db->Execute("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix, product_attribute_is_free, products_attributes_weight_prefix, attributes_display_only, attributes_default, attributes_discounted) values('" . (int)$pid . "', '" . (int)$optid . "', 0, '0.0000', '+', '1', '+', 0, 0, '1')");
    }
}

echo '<center style="color:#009900; font-size:14px;padding-top:50px;">Insert Attributes Success!</center>';

require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

打完收工!

posted @ 2014-11-26 10:08  小鱼阁工作室  阅读(914)  评论(0编辑  收藏  举报
Copyright © 小鱼阁工作室 版权所有 -zencart外贸建站,织梦企业建站,ecshop商城,二次开发,产品采集,模板修改!