我有 18,000 种产品,需要为特定客户群提供折扣。我不想玩 php!
我是在mysql中做的,在opencart数据库上操作。 0product_discount 是你需要操作的表。在您针对 product_id 为特定客户组创建折扣条目之前,它将为空。
# open your opencart database in mysql
# first create a file listing the product_id's you want the discount applied to: you can restrict the 'select' as desired.
# This selects all products. Or you can edit the file
select product_id into outfile '/home/junkfile' from 0product;
# outside mysql in a console run the following as a script file (this is for linux console should work in windows(???) idk
# read each product_id line from the file and creates an insert line with the proper data
while read line; do
echo "TRUNCATE TABLE 0product_discount;" >> testxx.sql
echo "" >> testxx.sql
# third item "3" is the customer_group_id
# quantity 1, priority 1 and price $1.0000
#OR you can use a percent discount
# dates are zeros for unlimited time frame
echo "INSERT INTO 0product_discount ( product_discount_id, product_id, customer_group_id, quantity, priority, price, date_start, date_end) VALUES ( '"${id}"','"${id}"', '3', '1', '1', '1.0000', '0000-00-00', '0000-00-00');" >> testxx.sql
done < /home/junkfile
#This creates a form of mysqldump text file
## now use mysql -u [user] -p < testxx.sql to load the 0product_discount table
### note that the 'truncate line, clears out your failures ready for your next try!!
不确定折扣价是否会显示在产品页面上,但确实会显示在结帐时。只需将客户添加到适当的组中即可。