不在VirtueMart 2中更新数据库中Products的新字段

时间:2014-08-22 07:44:32

标签: php mysql virtuemart

我已使用本指南:http://internet-studio.ca/vm2_new_field.php 在管理员面板中创建一个新字段。

与指南的不同之处在于我在product_prices中创建了一个字段。

  1. 首先我在表格中创建了一个新列:

    ALTER TABLE uhhu_virtuemart_product_prices ADD prices_gb DECIMAL(15,2)

  2. \管理员\部件\ com_virtuemart \视图\产品\ TMPL \ product_edit_price.php 我将此添加为在管理员中显示

    “>

    product-> price_giftbox?>“/> vendor_currency; ?>
  3. 管理员/语言/ EN-GB / EN-GB.com_virtuemart.ini 我用COM_VIRTUEMART_GIFT_BOX和COM_VIRTUEMART_GIFT_BOX_TIP更新了这个。

  4. /administrator/components/com_virtuemart/tables/products.php(来自指南) 我的:/administrator/components/com_virtuemart/tables/product_prices.php

    var $ price_gb = null;

  5. 但它没有这样的东西来放我的price_gb: 然后搜索以下代码行: $这 - > setTranslatable(阵列( 'PRODUCT_NAME', 'product_s_desc', 'product_desc', 'metadesc', 'metakey', 'customtitle'));

    我还去了文件:administrator / components / com_virtuemart / views / product / view.html.php 我把它放在最后。

    $product_empty_price = array(
    'virtuemart_product_price_id' => 0
    , 'virtuemart_product_id'         => $virtuemart_product_id
    , 'virtuemart_shoppergroup_id'    => NULL
    , 'product_price'                 => NULL
    , 'override'                      => NULL
    , 'product_override_price'        => NULL
    , 'product_tax_id'                => NULL
    , 'product_discount_id'           => NULL
    , 'product_currency'              => $vendor->vendor_currency
    , 'product_price_publish_up'      => NULL
    , 'product_price_publish_down'    => NULL
    , 'price_quantity_start'          => NULL
    , 'price_quantity_end'            => NULL
    , 'price_giftbox'                 => NULL
    );
    

    因此,当我填写我想要的所有字段和价格为ex的新字段时创建新产品的结果。 15 当我按下Save时它会变为0.00。

    当我用ex改变数据库的价格时。 15,当我刷新产品时,它显示正确的值:15。

    按“保存”按钮时,如何更新数据库?

1 个答案:

答案 0 :(得分:0)

找到解决方案:

要在按保存时更新价格,请点击此处:

administrator/components/com_virtuemart/models/product.php

我们寻找功能:

public function store (&$product, $isChild = FALSE) {

我们搜索PricetoStore列表,如下所示:

if (!$isChild){
                    //$pricesToStore['basePrice'] = $data['mprices']['basePrice'][$k];
                    $pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
                    $pricesToStore['override'] = (int)$data['mprices']['override'][$k];
                    $pricesToStore['virtuemart_shoppergroup_id'] = (int)$data['mprices']['virtuemart_shoppergroup_id'][$k];
                    $pricesToStore['product_tax_id'] = (int)$data['mprices']['product_tax_id'][$k];
                    $pricesToStore['product_discount_id'] = (int)$data['mprices']['product_discount_id'][$k];
                    $pricesToStore['product_currency'] = (int)$data['mprices']['product_currency'][$k];
                    $pricesToStore['product_price_publish_up'] = $data['mprices']['product_price_publish_up'][$k];
                    $pricesToStore['product_price_publish_down'] = $data['mprices']['product_price_publish_down'][$k];
                    $pricesToStore['price_quantity_start'] = (int)$data['mprices']['price_quantity_start'][$k];
                    $pricesToStore['price_quantity_end'] = (int)$data['mprices']['price_quantity_end'][$k];

- - - - > $ pricesToStore [' price_gb'] =(int)$ data [' mprices'] [' price_giftbox'] [$ k];                     }

然后在最后写下我们的文字!