在prestashop中为后台产品添加了选项卡和字段 - 如何正确保存输入?

I followed this tutorial on creating a custom module for a new tab and input in the back office

I don't want anything to do with languages - I have a simple text input where the user will input an INT.

In the tutorial it has us update the hookActionProductUpdate method:

public function hookActionProductUpdate($params)
{
// get the lines
// store the new field

$id_product = (int)Tools::getValue('id_product');
    if(!Db::getInstance()->update('number_lines', array('number_lines'=> pSQL(Tools::getValue('number_lines'))).' AND id_product = ' .$id_product ))
        $this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
}    

When I click 'save & stay' nothing happens.

My .tpl is showing it like this:

<div class="col-lg-1">
    <input type="text" name="number_lines" id="number_lines" value="{$number_lines|htmlentities}" />
</div>

Any help would be appreciated.

Overall purpose is just to have a text field that the user can enter a number into and it's saved into the database in the back office of a product.

I guess you have table called ps_number_lines with columns id_product and number_lines, so your update query should looks like:

Db::getInstance()->update('number_lines', 
    array('number_lines' => pSQL((int)Tools::getValue('number_lines'))), 
    'id_product = ' . $id_product)

because now you use it wrong, for better understanding check method update in classes/db/Db.php

/**
     * @param string $table Table name without prefix
     * @param array $data Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
     * @param string $where WHERE condition
     * @param int $limit
     * @param bool $null_values If we want to use NULL values instead of empty quotes
     * @param bool $use_cache
     * @param bool $add_prefix Add or not _DB_PREFIX_ before table name
     * @return bool
     */
    public function update($table, $data, $where = '', $limit = 0, $null_values = false, $use_cache = true, $add_prefix = true)
    {
        if (!$data)
            return true;

        if ($add_prefix)
            $table = _DB_PREFIX_.$table;

        $sql = 'UPDATE `'.bqSQL($table).'` SET ';
        foreach ($data as $key => $value)
        {
            if (!is_array($value))
                $value = array('type' => 'text', 'value' => $value);
            if ($value['type'] == 'sql')
                $sql .= '`'.bqSQL($key)."` = {$value['value']},";
            else
                $sql .= ($null_values && ($value['value'] === '' || is_null($value['value']))) ? '`'.bqSQL($key)."` = NULL," : '`'.bqSQL($key)."` = '{$value['value']}',";
        }

        $sql = rtrim($sql, ',');
        if ($where)
            $sql .= ' WHERE '.$where;
        if ($limit)
            $sql .= ' LIMIT '.(int)$limit;
        return (bool)$this->q($sql, $use_cache);
    }

You have to undergo quite an extensive amount of dev "just to have a text field" ^^

You have to create the field in the ps_producttable first (unsigned int).

Then add your fields to the Product class members (you need to override the product class first). Inside /override/classes/Product.php:

class Product extends ProductCore
{
    public $number_lines;

    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        Product::$definition['fields']['number_lines'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt');
        parent::__construct($id_product, $id_lang, $id_shop);
    }
...
}

Then you have to override the AdminProductsController to add said field in the form, with the right type.
Finally you have to assign the field to the product inside the controller's postProcess() function.