Jump to content
thirty bees forum

Please help: Bug: Not saving Customised Product Feature Values


Acer

Recommended Posts

Hi

I've encountered a bug where Customised Product Feature Values are not being saved in Admin.
Presaved features work, but it's impractical to create a value every single time first. This occurs on three of my sites, one on TB edge and the other two on 1.1.0. Using different browsers doesn't appear to be making a difference.

Has anyone encountered this one before and is there maybe a code fix I can implement?

Link to comment
Share on other sites

6 hours ago, datakick said:

Works fine for me

I've checked the logs and it appears to be filling up with this error when I try to add a custom product feature value:
 

[Tue Dec 01 12:47:23.753602 2020] [php7:warn] [pid 18120:tid 1916] [client ::1:52514] PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 55 in C:\\xamppnew\\htdocs\\development\\testsite\\classes\\Dispatcher.php on line 936, referer: http://localhost/development/testsite/admin3419jgisg/index.php?controller=AdminProducts&id_product=119&updateproduct&conf=4&key_tab=Features&token=ddb9b6bb5c007d48060cae23004fd3ec

This is line 936 in my Dispatcher.php
 

 if (preg_match($route['regexp'], $uri, $m)) {

 

This is the code I have in the Override/classes/Dispatcher.php file
 

<?php
class Dispatcher extends DispatcherCore
{
    /*
    * module: sturls
    * date: 2020-07-09 07:23:13
    * version: 1.0.0
    */
    protected function __construct()
    {
        if (Module::isEnabled('sturls')) {
            $module_inst = Module::getInstanceByName('sturls');
            $this->default_routes = array_merge($module_inst->hookModuleRoutes([]), $this->default_routes);
        }
        parent::__construct();
    }
    /*
    * module: sturls
    * date: 2020-07-09 07:23:13
    * version: 1.0.0
    */
    protected function loadRoutes($id_shop = null)
    {
        if ($id_shop === null) {
            $id_shop = (int)Context::getContext()->shop->id;
        }
        parent::loadRoutes($id_shop);
        if (Module::isEnabled('sturls')) {
            $module = Module::getInstanceByName('sturls');
            $language_ids = Language::getIDs(true, $id_shop);
            foreach($language_ids as $id_lang) {
                foreach($module->lang_field as $k => $v) {
                    $route_lang = Configuration::get($module->_prefix_st.strtoupper($k), $id_lang);
                    if ($v != $route_lang) {
                        foreach($this->default_routes as $route_id => $route) {
                            if (strpos($route['rule'], $v.'/') !== false || $route['rule'] == $v) {
                                if ($route['rule'] == $v) {
                                    $rule = str_replace($v, $route_lang, $route['rule']);
                                } else {
                                    $rule = str_replace($v.'/', $route_lang.'/', $route['rule']);    
                                }
                                
                                $this->addRoute(
                                    $route_id, 
                                    $rule, 
                                    $route['controller'],
                                    $id_lang,
                                    $route['keywords'], 
                                    isset($route['params']) ? $route['params'] : array(),
                                    $id_shop
                                );
                            }
                        }
                    }
                }    
            }
        }
    }
}


Initially I thought that it could be the "multiple values for a feature" module that I'm using, but I've since disabled that and I'm still getting this error...

Any ideas?

Edited by Theo
Link to comment
Share on other sites

Make sure your override is really not being used.

rename or remove the file override/classes/dispatcher.php completely from the override folder, and delete file cache/class_index.php

and then check again.

Edited by yaniv14
Link to comment
Share on other sites

Thanks for this. Seems like this dispatcher override is being used...
On a Local version of the site, after trying a few things (and bombing the site), I eventually restored the Modules folder from an old (recent enough) backup.
An lo and behold, it could save custom values for a feature again ūüėē¬†Wtf...
Unfortunately I can't try this shit on Live though as it's technically a different branch and its backups have this bug.

Probably going to be one of those weird unsolved mysteries... Not ideal...

However, does this not assist in giving a clue perhaps: ?

I've checked the logs and it appears to be filling up with this error when I try to add a custom product feature value:

[Tue Dec 01 12:47:23.753602 2020] [php7:warn] [pid 18120:tid 1916] [client ::1:52514] PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 55 in C:\\xamppnew\\htdocs\\development\\testsite\\classes\\Dispatcher.php on line 936, referer: http://localhost/development/testsite/admin3419jgisg/index.php?controller=AdminProducts&id_product=119&updateproduct&conf=4&key_tab=Features&token=ddb9b6bb5c007d48060cae23004fd3ec

This is line 936 in my Dispatcher.php
 

 if (preg_match($route['regexp'], $uri, $m)) {

Either way, I appreciate the assistance @yaniv14

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
√ó
√ó
  • Create New...