簡體   English   中英

不更新VirtueMart 2中數據庫上“產品”中的新字段

[英]not updating a new field in Products on the database in VirtueMart 2

我使用了該指南: http : //internet-studio.ca/vm2_new_field.php在管理員面板中創建一個新字段。

與指南的不同之處在於,我在product_prices中創建了一個字段。

  1. 首先,我在表中創建了一個新列:

    ALTER TABLE uhhu_virtuemart_product_prices添加prices_gb DECIMAL(15,2)

  2. \\ administrator \\ components \\ com_virtuemart \\ views \\ product \\ 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;

但是沒有這樣的東西來放置我的price_gb:然后搜索下面的代碼行:$ this-> setTranslatable(array('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當我按保存時,它變為0.00。

當我用ex更改數據庫的價格時。 15,當我刷新產品時,它顯示正確的值:15。

當我按“保存”按鈕時,如何更新數據庫?

查找解決方案:

要在我們按保存時更新價格,請轉到此處:

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]; }

然后在最后寫下我們的!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM