0

我有 2 个表,第product一个是 column price,第二个product_reward是 column points。我想用列*0.1points中的值更新该列。price所以积分=价格*01。

谢谢!

4

1 回答 1

0

您可以使用以下 sql 查询来更新产品的当前奖励积分。

UPDATE `oc_product_reward` rp SET rp.`points`=(SELECT p.price FROM `oc_product` p WHERE rp.`product_id` = p.`product_id`)*0.1  

之后,您必须更新管理部分的产品模型。插入和更新部分upload/admin/model/catalog/product.php

    if (isset($data['product_reward'])) {
        foreach ($data['product_reward'] as $customer_group_id => $product_reward) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "product_reward SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$customer_group_id . "', points = '" . (int)((float)$data['price'] * 0.1) . "'");
        }
    }
于 2013-03-09T17:04:38.623 回答