Input Field Value not Updating in Database



  • Hi,

    I am trying to add a dropdown field called minimum stay with values one week and one month for each room type in back office >catalog> Manage Room types >edit > configurations Tab . So that each room room type has its own minimum stay period.

    For this I added a field called minStay in ps_products table in database and I overrode the ProductCore class in override\classes.

    This is the code I have used.

    Class Product extends ProductCore{
        public $minStay;
     
        public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
        {
            self::$definition['fields']['minStay'] = array('type' => self::TYPE_STRING,
    'validate' => 'isGenericName', 'size' => 225, 'values' => array('oneMonth', 'oneWeek'), 'default' => 'oneMonth');
            parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
        }
    

    And I added my Minimum Stay Field in \qlo\backoffice\themes\default\template\controllers\products\configuration.tpl after num_child,

    smarty.png

    The field has came to front end and reading values from the database but it is not updating the value into the database when I click on Save or Save and Stay.

    Can you please help me resolving the issue.

    Thank You,
    Vamshi S.


  • Global Moderator

    @vamshi

    In order to save data the input type field name must be same in Db, object definition and input field.
    change select field name to

    <select class="form-control room_stay" name="minStay"> 
    

    If data is still not updated, cross check if override is working by dumping product object. If not then please backup and remove /cache/class_index.php



  • @shreesh

    Hi shreesh,

    It's working super cool now, Thank you so much for early response.


  • Global Moderator

    Hi @vamshi
    Glad to hear that!